|
-
June 20th, 2011, 01:24 PM
#1
[RESOLVED] Passing DropDownList
I have ASP.Net/C# sharp web project. There are several forms within the projects and some cases more than one form can have the same information in a dropdownlist. Because of this I want to keep the routine in a Class file that retrieves the data from a table. I use this code to populate the dropdownlist then call the list from one of the forms:
Code:
clsddlLocations.Items.Clear();
clsddlLocations.Items.Add(new ListItem("----Select Location----", string.Empty));
while (clsIncidentReporting.readerINCDRPT.Read())
{string newitem = (clsIncidentReporting.readerINCDRPT[1].ToString() + " - " + clsIncidentReporting.readerINCDRPT[2].ToString());
clsddlLocations.Items.Add(new ListItem(newitem, clsIncidentReporting.readerINCDRPT[0].ToString())); }
Then from a form:
clsIncidentReporting is the class name.
Code:
ddlDepartments.DataSource = clsIncidentReporting.clsddlDepartments.Items;
ddlDepartments.DataBind();
My problem is, when I try to get the VALUE the TEXT and VALUE appear to be the same. I use the same type of code to populate a dropdownlist where the routine is in code behind of a form and have no problem getting the VALUE value.
What am I doing wrong?
Last edited by godistop1; June 22nd, 2011 at 08:44 AM.
Reason: [] the code
-
June 22nd, 2011, 08:38 AM
#2
Re: Passing DropDownList
Anyone out there that can help me?
-
June 23rd, 2011, 04:25 PM
#3
Re: Passing DropDownList
Solve my problem using arrays.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|