Cross Page Posting for DropDownList
-
Hi: Can any one please tell me how can i get the value of a dropdownlist of the previous page. The code below doesn't work. if (Page.PreviousPage != null) { DropDownList ddlLF = (DropDownList)Page.PreviousPage.FindControl("ddlLeavingFrom"); DropDownList ddlGT = (DropDownList)Page.PreviousPage.FindControl("ddlGoingTo"); if (ddlLF != null) txtLF.Text = ddlLF.SelectedItem.ToString(); if (ddlGT != null) txtGT.Text = ddlGT.SelectedItem.ToString(); } Waiting..... for answer
-
Hi: Can any one please tell me how can i get the value of a dropdownlist of the previous page. The code below doesn't work. if (Page.PreviousPage != null) { DropDownList ddlLF = (DropDownList)Page.PreviousPage.FindControl("ddlLeavingFrom"); DropDownList ddlGT = (DropDownList)Page.PreviousPage.FindControl("ddlGoingTo"); if (ddlLF != null) txtLF.Text = ddlLF.SelectedItem.ToString(); if (ddlGT != null) txtGT.Text = ddlGT.SelectedItem.ToString(); } Waiting..... for answer
wot i understand by your question according to that you can use different methods to pass data between pages like Session variable Query string using cach..etc depends upon your requirment. simplest is session i think. //adding in session Session.Add("DDValue", DropDownList.SelectedItem); //taking value from session on another page or on same page string DropDownValue = Session["DDValue"].ToString(); Sorry if its not the solution you looking 4. Nav.
-
wot i understand by your question according to that you can use different methods to pass data between pages like Session variable Query string using cach..etc depends upon your requirment. simplest is session i think. //adding in session Session.Add("DDValue", DropDownList.SelectedItem); //taking value from session on another page or on same page string DropDownValue = Session["DDValue"].ToString(); Sorry if its not the solution you looking 4. Nav.
Thanks for your suggession but unfortunately when i retrive the values of Session Variables it returns null.
-
Hi: Can any one please tell me how can i get the value of a dropdownlist of the previous page. The code below doesn't work. if (Page.PreviousPage != null) { DropDownList ddlLF = (DropDownList)Page.PreviousPage.FindControl("ddlLeavingFrom"); DropDownList ddlGT = (DropDownList)Page.PreviousPage.FindControl("ddlGoingTo"); if (ddlLF != null) txtLF.Text = ddlLF.SelectedItem.ToString(); if (ddlGT != null) txtGT.Text = ddlGT.SelectedItem.ToString(); } Waiting..... for answer
What do you mean by "doesn't work"? You cannot get reference to the dropdownlist or the selected item returns empty? If you cannot get reference to teh dropdownlist then you might want to double check where you place the dropdownlist control in the source page. If it is placed inside another naming container, you will need to access the container before you want to access the dropdownlist. Cross-Page Posting in ASP.NET Web Pages [^]