Monday, March 26, 2012

Passing values to a Series of Dropdown lists on another page...

I know that the simple solution here is a standard page that simple changes a where its looking form the menu, but the higher up that is overseeing the request is die hard agianst the way it looks visually and how it opperates. So what I had to do is create two pages both with a series of 4 dropdownlists that allow selections that get you ultimately to an internal FAQ page.

My question is how can I pass the values of the first page's dropdownlists along to the second page. I created session variable but when I assign the values, I am sure you can guess the error, "Value is not a part of the list..blah, blah, blah". So how can I get the values to match from the previous page's selections?

When you get this error, that means your second page's list doesn't have this value list.

1. Check the session value to make sure your passed value is correct, and is the one in your second page's ddl item list.

2. Add a null ListItem in your second page ddl. catch it to the default selected item if error happens.

Hope it helps


This is exactly what is happening. Is there a way to force the DDL's to complete there SQL which would populate it's lists based on the selection of the previous DDL's value during the Page load event?


Does anyone have any ideas or points in the right direction as to how this can be done. I'm sure it is going to take some extensive coding, but being probably less than a novice and a true "hack" I have no idea where to start.


Gatorzlair:

This is exactly what is happening. Is there a way to force the DDL's to complete there SQL which would populate it's lists based on the selection of the previous DDL's value during the Page load event?

Hi,

Based on my understanding, you want to bind the DropDownLists by the parameters passed from the other page. If I have misunderstood you, please feel free to let me know.

We can bind the DropDownLists by parameters in the Page Load event. First, we need to get the parameters and then get the data source by them to bind the DropDownLists. The following is the simple example:

protected void Page_Load(object sender, EventArgs e) {//Get parameters.string strPara1 = Request.QueryString["Parameter1"];string strPara2 = Request.QueryString["Parameter2"];//Get Data source by the parameters. DataSet ds = GetDataSource(strPara1, strPara2);//Bind DropDownList. DropDownList1.DataSource = ds; DropDownList1.DataTextField ="**"; DropDownList1.DataValueField ="**"; DropDownList1.DataBind(); }

I hope this helps.

0 comments:

Post a Comment