【发布时间】:2012-09-07 15:20:56
【问题描述】:
我将如何实现:
用户可以在Textbox1 中输入任何文本,然后单击Submitbtn1,然后在Gridview1 中显示结果。 Clearbtn1用于清除Textbox1中的所有文本。
这一切都将在 Visual Studio ASP.NET Web 应用程序中完成。
这是我到目前为止所做的:
namespace SearchApplication
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void EmptyTextBoxValues(Control parent)
{
foreach (Control c in parent.Controls)
{
if ((c.Controls.Count > 0))
{
EmptyTextBoxValues(c);
}
else
{
if (c.GetType().ToString().Equals("System.Web.UI.WebControls.TextBox"))
{
((TextBox)(c)).Text = "";
}
else
{
//do nothing
}
}
}
}
protected void Button2_Click(object sender, EventArgs e)
{
EmptyTextBoxValues(this.Page);
}
protected void Button1_Click1(object sender, EventArgs e)
{
}
}
}
【问题讨论】: