asp.net中怎么样获取页面中表格里面所有的checkbox
1个回答
2013-07-15
展开全部
private static void ClearCS_InfoTxtAndDrop(Page page)
{
#region //循环页面所有的控件找出checkbox for (int i = 0; i < page.Controls.Count; i++)
{
if (page.Controls[i].ToString() == "System.Web.UI.HtmlControls.HtmlForm")
{
for (int j = 0; j < page.Controls[i].Controls.Count; j++)
{
if (page.Controls[i].Controls[j].GetType() == typeof(TextBox))
{ ((TextBox)page.Controls[i].Controls[j]).Text = ""; }
if (page.Controls[i].Controls[j].GetType() == typeof(DropDownList))
{
if (page.Controls[i].Controls[j].ID == "drop_CS_owner" || page.Controls[i].Controls[j].ID == "drop_CS_contact")
{
//什么也不做不清空·
}
else
{
if (((DropDownList)page.Controls[i].Controls[j]).Items.Count != 0)
{
((DropDownList)page.Controls[i].Controls[j]).SelectedIndex = 0;
}
}
}
}
}
}
#endregion
}
{
#region //循环页面所有的控件找出checkbox for (int i = 0; i < page.Controls.Count; i++)
{
if (page.Controls[i].ToString() == "System.Web.UI.HtmlControls.HtmlForm")
{
for (int j = 0; j < page.Controls[i].Controls.Count; j++)
{
if (page.Controls[i].Controls[j].GetType() == typeof(TextBox))
{ ((TextBox)page.Controls[i].Controls[j]).Text = ""; }
if (page.Controls[i].Controls[j].GetType() == typeof(DropDownList))
{
if (page.Controls[i].Controls[j].ID == "drop_CS_owner" || page.Controls[i].Controls[j].ID == "drop_CS_contact")
{
//什么也不做不清空·
}
else
{
if (((DropDownList)page.Controls[i].Controls[j]).Items.Count != 0)
{
((DropDownList)page.Controls[i].Controls[j]).SelectedIndex = 0;
}
}
}
}
}
}
#endregion
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询