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.
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 )
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