我正在尝试在行数据绑定中适合ASP.NET gridView
中的文本框。在这里,它没有在cell.to中进行适当的调整以适合它。
在行数据绑定中,我使用
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");
}
}
如何在网格单元格中适当地拟合它。
发布于 2013-09-26 00:30:37
我正在试这个,它工作得很好..
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为我做了这个把戏:)
https://stackoverflow.com/questions/19005925
复制相似问题