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

Last Reply 4 months ago By pandeyism

Posted 4 months 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.

    <asp:DropDownList CssClass="form-control dropdown" ID="ddl_nprice" runat="server"
        DataSourceID="SqlDataSource4" DataTextField="nozzle_price" DataValueField="company_email"
    <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))">
            <asp:ControlParameter ControlID="ddl_comp" PropertyName="SelectedValue" Name="company_email"
            <asp:Parameter DefaultValue="0" Name="nozzle_lph" Type="Int32"></asp:Parameter>
            <asp:Parameter DefaultValue="0" Name="nozzle_price" Type="Double"></asp:Parameter>


You are viewing reply posted by: pandeyism 4 months ago.