i have a DropDownList on aspx page
<asp
ropDownList id="ProdType" runat="server" CssClass="HomeText" AutoPostBack="true"></asp
ropDownList>
which i have filled it up in page_load
private void Page_Load(object sender, System.EventArgs e)
{
String Qid=Request.QueryString["id"];
String SelCmd="Select * from TblFRProduct";
SqlCommand myCommand=new SqlCommand(SelCmd,myConnection);
myCommand.Connection.Open();
SqlDataReader dr=myCommand.ExecuteReader();
ProdType.DataTextField="Prod_Name";
ProdType.DataValueField="Prod_Id";
ProdType.DataSource=dr;
ProdType.DataBind();
dr.Close();
myCommand.Connection.Close();
}
i want whenever the selecteditem in DropDownList has been changed the page should be redirected to itself with a querystring. so i did
private void ProdType_SelectedIndexChanged(object sender, System.EventArgs e)
{
String Str="memacc.aspx?id="+ProdType.SelectedItem.Value;
Response.Redirect(Str);
}
suppose the dropdownlist has 5 items
1-a
2-b
3-c
4-d
5-e
at first time a is selected and now i select item 3 so i should i have
Response.Redirect("memacc.aspx?id=3");
but i always have memacc.aspx?id=1
always the first item has been shown as the selected item. any idea for that?
<asp
which i have filled it up in page_load
private void Page_Load(object sender, System.EventArgs e)
{
String Qid=Request.QueryString["id"];
String SelCmd="Select * from TblFRProduct";
SqlCommand myCommand=new SqlCommand(SelCmd,myConnection);
myCommand.Connection.Open();
SqlDataReader dr=myCommand.ExecuteReader();
ProdType.DataTextField="Prod_Name";
ProdType.DataValueField="Prod_Id";
ProdType.DataSource=dr;
ProdType.DataBind();
dr.Close();
myCommand.Connection.Close();
}
i want whenever the selecteditem in DropDownList has been changed the page should be redirected to itself with a querystring. so i did
private void ProdType_SelectedIndexChanged(object sender, System.EventArgs e)
{
String Str="memacc.aspx?id="+ProdType.SelectedItem.Value;
Response.Redirect(Str);
}
suppose the dropdownlist has 5 items
1-a
2-b
3-c
4-d
5-e
at first time a is selected and now i select item 3 so i should i have
Response.Redirect("memacc.aspx?id=3");
but i always have memacc.aspx?id=1
always the first item has been shown as the selected item. any idea for that?