Results 1 to 2 of 2

Thread: Displaying Data in DropDownList

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Displaying Data in DropDownList

    Is it possible to show 2 appended values in one dropdown list.

    EG, I Want to show Firsname Lastname in the dropdown list below, but looks like this is only limited to showing one field (Firstname) ?

    <aspropDownList id="ddDept" runat="server" Rows="1"
    DataTextField="FirstName" DataValueField="DepartmentID" />

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    you can do something like this (C#)
    Code:
    SqlConnection Conn = new SqlConnection(your connectionstring);
    SqlCommand Comm = new SqlCommand(your query, Conn);
    SqlDataReader reader;
    
    try
    {
       Conn.Open();
       reader = Comm.ExecuteReader();
    
       while(reader.Read())
       {
          ComboBox1.Items.Add(reader["firstName"] + " " + reader["lastName"]);
       }
    
       reader.Close();
       Conn.Close();
    }
    catch(Exception ex)
    {
       MessageBox.Show("Error: " + ex.Message.ToString());
    }
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

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