0

ドロップダウンリストがあり、次のようにいくつかの項目を追加しました

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

そしてデータソースで

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

ロードするとリストがクリアされ、新しいアイテムがロードされます。ページのロード時にカスタム バインダーを作成したくありません。データソースからバインドしている間、追加したアイテムをリストに維持するにはどうすればよいですか?

4

1 に答える 1

0

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.

于 2010-05-24T16:28:30.623 に答える