Posted on: 7/30/2014 4:03:52 PM | Views : 396

In a WebPage there are many TextBoxes, DropDownLists and Labels and These controls are within a Table
I have a button to clear all controls above to empty.
My code in C# below does not work. Any help?
protected void ButtonClear_Click(object sender, EventArgs e) { ContentPlaceHolder placeHolder = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1"); Table tb = (Table)placeHolder.FindControl("Table1");
foreach(Control c in tb.Controls) { if (c is TextBox) ((TextBox)c).Text = ""; else if (c is DropDownList) ((DropDownList)c).SelectedIndex = -1; else if (c is Label) ((Label)c).Text = ""; } }

Go to the complete details ...