The gridview has multiple rows and columns and each cell has a textbox, validator controls. The columns are generated dynamically, and I would like to clear all the textboxes.
This is not working. Where am I going wrong
protected void btnClear_Click(object sender, EventArgs e)
{
if(gvMain.Rows.Count > 0)
{
foreach(GridViewRow gvr in gvMain.Rows)
{
foreach(TableCell tc in gvr.Cells)
{
if(tc.HasControls())
{
for(int i=0;i<tc.Controls.Count;i++)
{
if(tc.Controls[i] is TextBox)
{
TextBox tb = (TextBox)tc.Controls[i];
tb.Text= "";
}
}
}
}
}
}
}
Pravesh Singh
14-Nov-2013Here is the solution
Hope this will help