0
我将如何实现这个:搜索框,按钮和GridView
用户可以在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)
{
}
}
}
感谢清楚......但我有麻烦键入搜索和GridView中返回的搜索结果仍然 – user1179083
您可以发布更完整的代码? – Roland
想通了,谢谢,我必须使用表适配器功能等。 – user1179083