I have this code to send variables to a datagrid on another page
protected void Button1_Click(object sender, EventArgs e)
{
int agent = int.Parse(txtAgencyCode.Text);
Session["para1"] = agent;
Button1.Attributes.Add("onclick", "window.open('http://localhost:50771/WebSite4/Datagrid.aspx'); return false;");
}
protected void btnTitleSearch_Click(object sender, EventArgs e)
{
Session["para2"] = txtTitleSearch.Text;
btnTitleSearch.Attributes.Add("onclick", "window.open('http://localhost:50771/WebSite4/Datagrid.aspx'); return false;");
}
and this code on the other page that uses the session variable from button one
protected void Page_Load(object sender, EventArgs e)
{
int field1 = (int)(Session["para"]);
localhost.Service ws = new localhost.Service();
GridView1.DataSource = ws.GetJobsByAgencyID(field1);
GridView1.DataBind();
}
What i cannot figure out is how to make an if statement (or even if it will be an if statement that is used) to decide which parameter is passed to my datagrid.
For info there will be another 3- 4 controlos on the default page (Only one of which will be activated) and the parameters will take diffeent types.
EDIT
So sorry you all found my question hard to understand, im not by any means a profesional or even what yuo may call a competent.
James Hill and Ravi gave me pretty much what I was after (need to test but looks like it). Thanks all for trying 😀
if i understood correctly, you need branching based on value stored in your session,
you can try like this