CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Apr 2011
    Location
    Tennessee
    Posts
    19

    [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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured