2013-09-25 2 views
0

Я пытаюсь установить текстовое поле в ASP.NET gridView в строке данных. здесь он неправильно регулируется в cell.to, чтобы соответствовать ему правильно.Fit Текстовое поле в ячейке excel?

В строковых данных связан я использую

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
    { 
     if (e.Row.RowType == DataControlRowType.DataRow) 
     { 
      e.Row.Attributes.Add("onclick", "this.style.backgroundColor='orange'"); 
      e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'"); 
      e.Row.Cells[2].Width = new Unit("700px"); 
      TextBox txtAddress = new TextBox(); 
      txtAddress.ReadOnly = false; 
      e.Row.Cells[2].Controls.Add(txtAddress); 
      e.Row.Cells[2].Style.Add("text-align", "center"); 
      txtAddress.Text = e.Row.Cells[2].Text; 
      GridView1.Attributes.Add("style", "table-layout:fixed"); 
     } 
    } 

Как установить его должным образом в ячейке сетки.

+0

1000px? 360 пикселей? это огромные размеры. –

+0

На самом деле его поле комментариев ... и клиент хотят увидеть полный комментарий в gridview –

+0

изменить текстовый текст с текстового поля на многострочный – amitesh

ответ

0

Я пытаюсь это и его работает отлично ..

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 
     { 
      if (e.Row.RowType == DataControlRowType.DataRow) 
      { 
       e.Row.Attributes.Add("onclick", "this.style.backgroundColor='orange'"); 
       e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'"); 
       e.Row.Cells[2].Width = new Unit("700px"); 
       TextBox txtAddress = new TextBox(); 
       txtAddress.ReadOnly = false; 
       //txtAddress.Style = "width:100%;"; 
       txtAddress.Style.Add("width", "99%"); 
       e.Row.Cells[2].Controls.Add(txtAddress); 
       e.Row.Cells[2].Style.Add("text-align", "center"); 
       txtAddress.Text = e.Row.Cells[2].Text; 
       GridView1.Attributes.Add("style", "table-layout:fixed"); 
      } 
     } 

100% математически точным, но 99 сделал трюк для меня :)

Смежные вопросы