Dropdown list bound to object data source - how to update on a button click
- by Jen
This is probably something really stupidly simple..
I have a drop down list bound to an object data source. I have set AppendDataBoundItems to true so that I can have an initial select.
<asp:DropDownList ID="Accommodations1" runat="server" AutoPostBack="true" DataTextField="AccommodationTypeDescription" DataValueField="Id" OnDataBound="Accommodations1_DataBound" onSelectedIndexChanged="Accommodations1_SelectedIndexChanged" Width="200px" DataSourceID="AccommodationDs" AppendDataBoundItems="true">
<asp:ListItem Text="Select" Value=""></asp:ListItem>
</asp:DropDownList>
<asp:ObjectDataSource ID="AccommodationDs" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="ListByPropertyId" TypeName="PropertyAccommodationController">
<SelectParameters>
<asp:Parameter Name="PropertyId" Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
I have a button which adds an accommodaton - so after that happens I need the dropdown list to update to include the new accommodation. So I've tried calling databind on the dropdownlist, and databind on the datasource - and nothing is making this dropdown list update.
eg. PropertyAccommodations1.DataBind();
Could someone please let me know what I'm doing wrong. Originally I thought it was due to an update panel issue.. but I've removed the update panel and it still doesn't work (and checked the master page doesn't include an update panel).
Thanks!!