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:
Then from a form: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())); }
clsIncidentReporting is the class name.
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.Code:ddlDepartments.DataSource = clsIncidentReporting.clsddlDepartments.Items; ddlDepartments.DataBind();
What am I doing wrong?




Reply With Quote