如何使用后面的代码在Gridview的itemtemplate中的控件中添加readonly属性? 我尝试过使用rowdatabound但总是得到null
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){
if(e.Row.RowType == DataControlRowType.DataRow)
{
Textbox mytxt = e.Row.FindControl("txtDate") as Textbox;
}
}
我尝试在asp.net页面添加readonly属性,但我无法获取文本框值(我使用javascript日历输入文本框)
答案 0 :(得分:0)
试
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){
if(e.Row.RowType == DataControlRowType.DataRow)
{
TextBox mytxt = e.Row.FindControl("txtDate") as TextBox;
mytxt.Attributes.Add("readonly", "readonly");
}
}