How would I implement this:
A user can enter any text in Textbox1, then click Submitbtn1 and then show results in a Gridview1. Clearbtn1 is used to clear all text in the Textbox1.
This would be all done in Visual Studio ASP.NET Web application.
This is what I have done so far:
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)
{
}
}
}
One tip. Do not do :
Do
As for other things.
When Submit Button is clicked you would get some data / create some data and bind it to the grid using
Regarding clearing the textbox. If you used normal Asp.net TextBox that you put outside of the Grid, like
You do not need EmptyTextBoxValues. You can just do Textbox1.Text = “”