I have one DropDownList and Button on my page.
After I select the dropdownlist and click the button, it will redirect to same page, and It has to show in dropdownlist what I select before redirect
Here is my code
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
//ASPxGridView1.Visible = false;
}
else
{
if(Request.QueryString["ReqID"] != null)
ddlRequestNo.SelectedValue = Request.QueryString["ReqID"].ToString();
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
Response.Redirect("GPApproveCheque.aspx?ReqID="+ddlRequestNo.SelectedItem.Text.ToString());
}
When I see the url, It is showing what is choose on first time
for example
On my drop down list if I have value
111
222
333
444
1.Once I select 222, I can see in the url bar like below
http://localhost:55047/GPApproveCheque.aspx?ReqID=222
2.Still drop down list is showing 111
3.When I select second or third time a different options from dropdown, it will show in the url the same old one 222 and dropdownlist never change 111
Update
When I try this below code, it throws System.NullReferenceException
ddlRequestNo.SelectedIndex = ddlRequestNo.Items.IndexOf(ddlRequestNo.Items.FindByText(Request.QueryString["ReqID"].ToString()));
Which it returns null for ReqID. How it is possible, Because, I am passing parameter like "GPApproveCheque.aspx?ReqID="+ddlRequestNo.SelectedItem.Text.ToString()
Page load function execute before it receive parameter