views:

12

answers:

1

Hi, I have a drop down list, and I added some items in it as follows

        <asp:DropDownList ID="ddlInsAuther" runat="server" 
            DataSourceID="ObjectDataSourceInsAuthers" DataTextField="AutherName" 
            DataValueField="AutherID">
        <asp:ListItem Value="-1">No Authers</asp:ListItem>
        </asp:DropDownList>

And in Datasource

        <asp:ObjectDataSource ID="ObjectDataSourceInsAuthers" runat="server" 
            SelectMethod="GetAll" TypeName="MyProject.BusinessLayer.AuthersFactory">
        </asp:ObjectDataSource>

When it loads it clears the list and loads the new items, I don't want to make a custom binder on page load, how can I maintain my added items in the list while binding from datasource?

A: 

You can add AppendDataBoundItems="true" to the DropDownList. Be aware though, if you bind multiple times it will keep adding the items over and over. You would get around this by putting the call to DataBind() in a if (!IsPostBak) but I am not sure if you can do this with an ObjectDataSource.

Ben Robinson