954,593 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to create DropDownList with any table

Hi...

I am creating function searching on my web with drop down list, text box and button search. The following code:

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
 OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
     <asp:ListItem></asp:ListItem>
     <asp:ListItem Value="Pelanggan Rumah"></asp:ListItem>
     <asp:ListItem Value="Meter Besar"></asp:ListItem>
     <asp:ListItem Value="Kios Air"></asp:ListItem>
     <asp:ListItem Value="Pipa"></asp:ListItem>
     <asp:ListItem Value="Pembayaran"></asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="CariText" runat="server" Width="100px" Height="23px" CssClass="text_boxt_search"></asp:TextBox>
<asp:Button ID="Find" runat="server" Text="Search" Width="61px" CssClass="style105"  Height="25px" />


And this is code behind:

Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        Dim strConnect As String = Nothing
        strConnect = Session("Data Source=192.168.1.88;Initial Catalog=ATBGISMAPDB;Persist Security Info=True;User ID=gis;Password=Pa5word@tb")



        Dim a As String = "SqlDataSourceCustomer" 'datasourceID'
        Dim b As String = "SqlDataSourceTank" 'datasourceID'
        Dim c As String = "SqlDataSourceKiosk" 'datasourceID'
        Dim d As String = "SqlDataSourcePipa" 'datasourceID'


        If DropDownList1.SelectedItem.Value = a Then
            Query = "SELECT * FROM DBCUSTOMER where a = '" & LabelDDL.Text & "'"
        ElseIf DropDownList1.SelectedItem.Value = b Then
            Query = "SELECT * FROM METER_MAIN where b = '" & LabelDDL.Text & "'"
        ElseIf DropDownList1.SelectedItem.Value = c Then
            Query = "SELECT * FROM KIOSK where c = '" & LabelDDL.Text & "'"
        ElseIf DropDownList1.SelectedItem.Value = d Then
            Query = "SELECT * FROM PIPELINE_NEW where d = '" & LabelDDL.Text & "'"
        End If
    End Sub


But, with above code the function not running yet. Can anyone help me?
'sorry for my english'

kikiwisaka
Newbie Poster
3 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
 

Can you plz explain what error are you getting while running the above code??

geniusvishal
Junior Poster in Training
58 posts since Jan 2012
Reputation Points: 9
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: