如何在gridview中将gridview中的所有控件设置为只读 [英] How to set all controls in gridview to readonly in web application
本文介绍了如何在gridview中将gridview中的所有控件设置为只读的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在这样迭代
I am iterating like this
foreach (Control c in gvFormula.Rows[gvFormula.EditIndex].Controls)
{
// How to make use of this loop
}
推荐答案
我认为正确的方法是
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
这篇关于如何在gridview中将gridview中的所有控件设置为只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文