Let's see, how we could do this using query string:
In the Search Button (First webpage) event handler put the code like:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Staff.aspx?Name=" + txtBx_Request.Text);
}
And on the second form page load, get the query string and send the query string to retrieve the data from database. After that we bind the data into a data grid.
protected void Page_Load(object sender, EventArgs e)
{
string reqName = Request.QueryString["Name"];
if (reqName != null && reqName != "")
{
Label1.Text = "You queried for the person having name: " + reqName;
//Getting the data from database
DataSet resultDataSet = GetDataFromDatabase(storedProcName, reqName);
if (resultDataSet.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = resultDataSet.Tables[0];
GridView1.AutoGenerateColumns = true;
GridView1.DataBind();
}
else
{
Label1.Text += "<br/><br/>Sorry, No data found!";
}
}
}
No comments:
Post a Comment