Click here to Skip to main content
15,908,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...
I am developing a web application using ASP.NET and c#.
I am passing values from Page1.aspx to Page2.aspx through querystring.
I am able to retrieve the values in Textbox,but I want to retrieve value in Dropdownlist.
Like,if i am passing Status in Querystring...then my Dropdownlist on page2 should show that Status.
Please mention any codes for this...
Posted
Comments
R. Giskard Reventlov 23-Aug-10 4:49am    
What have you already tried? How did that work out? What specific issues do you have with that?

C#
if(Request.QueryString["x"] != null)
dropDownList1.SelectedValue = Request.QueryString["x"].toString();


Thanks
Hiren Solanki
 
Share this answer
 
If you read the query string, you can do whatever you like with the data you pull from there.
 
Share this answer
 
protected void Page_Load(object sender, EventArgs e)
{
dropDownList1.SelectedValue = Request.QueryString[querystring];
}


This is provided that the Value field property of the DropDownList is set to values of the status(s) you are passing thru the querystring.
 
Share this answer
 
string ddl_Exchange = Request.QueryString["Exchange"].ToString(); ddlExchange.ClearSelection();
ddlExchange.Items.FindByText(ddl_Exchange).Selected = true;
 
Share this answer
 
Suppose you having one textbox on page1.aspx
then on Button Click


C#
protected void Button1_Click(object sender, EventArgs e)
    {
        string status = TextBox1.Text;
        Response.Redirect("page2.aspx?status="+status+"");
    }



and on page2.aspx on page_load
C#
protected void Page_Load(object sender, EventArgs e)
    {
        DropDownList1.Items.Add(Request.QueryString["status"].ToString());
    }


Do this u'll Get the value of textbox on page2.aspx in dropdownlist :)
 
Share this answer
 
string ddl_Exchange = Request.QueryString["Exchange"].ToString();
ddlExchange.ClearSelection();
ddlExchange.Items.FindByText(ddl_Exchange).Selected = true;
 
Share this answer
 
protected void Page_Load(object sender, EventArgs e)
{
dropDownList1.SelectedItem.Text = Request.QueryString["your_id"].ToString();
}


Hey try this. This would be definately work.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900