且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在gridview中将gridview中的所有控件设置为只读

更新时间:2021-08-01 02:46:22

我认为正确的方法是





I think the right way to go is


foreach (GridviewRow row in gvFormula.Rows)
{
    //should you have a TextBox called txt1
    ((TextBox)row.FindControl("txt1")).ReadOnly = true;
    //or if you need invisible
    ((TextBox)row.FindControl("txt1")).Visible = false;
    
    //and so on and so on...
}





如果需要,你也可以在RowDataBound事件上使用



You can also use it on RowDataBound event if you need