Retain (Keep) DropDownList selected value on PostBack using C# and VB.Net in ASP.Net

Last Reply 10 days ago By pandeyism

Posted 11 days ago

In below code when i am selecting a value from dropdown list after postback the dropdown list select first value of list but not the actual selected value. so please help me.

<td>
    <asp:DropDownList CssClass="form-control dropdown" ID="ddl_nprice" runat="server"
        DataSourceID="SqlDataSource4" DataTextField="nozzle_price" DataValueField="company_email"
        AutoPostBack="true">
    </asp:DropDownList>
    <asp:SqlDataSource runat="server" ID="SqlDataSource4" ConnectionString='<%$ ConnectionStrings:Mycon %>'
        SelectCommand="SELECT [company_email], [nozzle_lph], [nozzle_price] FROM [company_sprinkler_data] WHERE (([company_email] = @company_email) AND ([nozzle_lph] != @nozzle_lph) AND ([nozzle_price] != @nozzle_price))">
        <SelectParameters>
            <asp:ControlParameter ControlID="ddl_comp" PropertyName="SelectedValue" Name="company_email"
                Type="String"></asp:ControlParameter>
            <asp:Parameter DefaultValue="0" Name="nozzle_lph" Type="Int32"></asp:Parameter>
            <asp:Parameter DefaultValue="0" Name="nozzle_price" Type="Double"></asp:Parameter>
        </SelectParameters>
    </asp:SqlDataSource>
</td>

 

You are viewing reply posted by: pandeyism 10 days ago.