Quote:
You can use SESSION value for this purpose, using this value you need to find Item from dropdown
protected void Page_Load(object sender, EventArgs e)
{
DataTable subjects = new DataTable();
if (Page.IsPostBack == false)
{
using (SqlConnection con = new SqlConnection(constring))
{
SqlDataAdapter adapter = new SqlDataAdapter("SELECT name FROM Table", con);
adapter.Fill(subjects);
con.Open();
DropDownList1.DataSource = subjects;
DropDownList1.DataTextField = "name";
DropDownList1.DataValueField = "name";
DropDownList1.DataBind();
if(!String.IsNullOrEmpty(Session["selectedval"] as string))
{
DropDownList1.SelectedIndex =
DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(Session["selectedval"].ToString()));
}
con.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string selectedval = DropDownList1.SelectedItem.Value;
Session["selectedval"] = selectedval;
Response.Redirect("default.aspx?val="+selectedval);
}