Results 1 to 3 of 3

Thread: Display two columns in dropdownlist

  1. #1
    Join Date
    Apr 2009
    Posts
    87

    Display two columns in dropdownlist

    I am trying to display two columns in a vb.net dropdownlist. One of the problem we encounter is displaying data of dropdownlist in column such as name, id, address. Is there any way to display two column in dropdown list. I don't want to use multiple-column dropdown list and list box it doesn't display data simultaneously.Thank you in advance.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Display two columns in dropdownlist

    SELECT LName + REPLICATE ('.', 20 – len(LName)) + FirstName AS FullName FROM name of user (Lname will always be 20 char way from the first char of first name, the space in between padded with "...." )

    SELECT LName + SPACE (20 – len(LName)) + FirstName AS FullName FROM name of user(Lname will always be 20 char way from the first char of first name, the space in between padded with spaces )

  3. #3
    Join Date
    Jan 2009
    Posts
    199

    Re: Display two columns in dropdownlist

    Code:
    Public Sub PopulateNextCombo(ByVal sender As Object, ByVal e As System.EventArgs)
         Dim Data1  As DropDownList
         Dim user1 as DropDownList
         Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
         Dim myCommand As SqlCommand = New SqlCommand("sp_das_state_sel", myConnection)
         Dim myDataReader As SqlDataReader
    
         myCommand.CommandType = CommandType.StoredProcedure
         Try
              myConnection.Open()
              myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
             Data1 = CType(DG_Combo.Items.Item(DG_Combo.EditItemIndex).FindControl("cboState2"), DropDownList)
                  Data1.DataSource = myDataReader
                  Data1.DataBind()
              user1 = CType(DG_Combo.Items.Item(DG_Combo.EditItemIndex).FindControl("cboState"), DropDownList)
             Data1.SelectedIndex =  user1.SelectedIndex
    
         Catch SQLexc As SqlException
              lblStatus.Text = "Error while Generating Data. Error is " & SQLexc.ToString()
    
         Finally
              If Not myDataReader Is Nothing Then
                   myDataReader.Close()
              End If
    
              If Not myConnection Is Nothing AndAlso ((myConnection.State And ConnectionState.Open) = ConnectionState.Open) Then
                   myConnection.Close()
              End If
         End Try
    End Sub

Similar Threads

  1. How to create collection of dropdownlist, datatextfield ?
    By Jevin in forum Software Development
    Replies: 2
    Last Post: 16-06-2009, 09:02 AM
  2. Help to update the DropDownList
    By HiSpeed in forum Software Development
    Replies: 2
    Last Post: 23-04-2009, 11:37 PM
  3. How to select dropdownlist default selected
    By Integer in forum Software Development
    Replies: 5
    Last Post: 18-03-2009, 11:41 PM
  4. Putting a dropdownlist in the column header of a GridView
    By ShonaliB in forum Software Development
    Replies: 4
    Last Post: 10-02-2009, 06:52 PM
  5. Submenu in two columns
    By wazzeledozzle in forum Tips & Tweaks
    Replies: 1
    Last Post: 24-09-2008, 07:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,559,030.70321 seconds with 17 queries