0

I have a DropDownList that is populated from an ObjectDataSource

<asp:DropDownList ID="ddlDepartment" runat="server" AutoPostBack="True" 
            DataSourceID="odsGetDeptByFaculty" DataTextField="Dept" DataValueField="FID" 
            onselectedindexchanged="ddlDepartment_SelectedIndexChanged">
        </asp:DropDownList>
        <asp:ObjectDataSource ID="odsGetDeptByFaculty" runat="server" 
            SelectMethod="usp_GetDeptByFaculty" TypeName="DataLayer.StoredProcs">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlFaulty" Name="fCode" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>

My problem is when I run the program and select the option from the dropdownlist when the postback happens it returns to the first value in the list. Please help me nip resolve this issue. Many thanks in advance.

2
Contributors
1
Reply
5
Views
6 Years
Discussion Span
Last Post by Freon22
0

Thats because the dropdownlist is repopulating on postback. What you are going to have to do is populate the dropdownlist from the code behind page within a

if (!IsPostBack)

This way it will not repopulate on postback.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.