hi, there i am coming up with a dropdownlist, where the data will be in the sql database. The data then is retrieved from the database using dropdownlist. I am not sure if this codes are right. please help.

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CourierSystemConnectionString %>" 
        SelectCommand="SELECT [DelName] FROM [DelBoy_Table]">
    
    </asp:SqlDataSource>


<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" 
AppendDataBoundItems="true" DataTextField="DelBoy" DataValueField="Data" AutoPostBack="true" Height="81px" Width="179px">
        </asp:DropDownList>

You have used 'Data' as the DataValueField in the DropDownList.

Therefore the 'SelectCommand' property should be as below

SelectCommand="SELECT [DelName], [Data] FROM [DelBoy_Table]"

Here I assumed that the DelBoy_Table has a column by the name 'Data'

Actually, i only have one column called 'delboy'. So i just insert 'delboy' into datavaluefield. However, i can't retrieve the data from database into the drodownlist. should i add any sql procedure?please help. i am short of time.

hi, there i am coming up with a dropdownlist, where the data will be in the sql database. The data then is retrieved from the database using dropdownlist. I am not sure if this codes are right. please help.

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:CourierSystemConnectionString %>" 
        SelectCommand="SELECT [DelName] FROM [DelBoy_Table]">
    
    </asp:SqlDataSource>


<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" 
AppendDataBoundItems="true" DataTextField="DelBoy" DataValueField="Data" AutoPostBack="true" Height="81px" Width="179px">
        </asp:DropDownList>

i think u have to write code like datatextfield="field which u want show in dropdown" and datavaluefield="releted id "

i am able to get it, but how am i going to select the delivery boy name and send it to the next page? How am i going to use the button. i am not sure of the code. This is because, i need to use the gridview as well. please help me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.