Reputation: 5167
In ObjectDataSource my checkbox is always ignored. My update method always receives NULL. What am I doing wrong here?
Thanks.
<asp:CheckBox ID="CheckBoxSort" runat="server" Checked="true" />
CheckBox is on its own. It is not contained in any other .net controls. ....
<asp:ObjectDataSource ID="odsProfileItems" runat="server" SelectMethod="GetProfileItemsForCategory" TypeName="Valero.WEB.BO.StoreProfile.ProfileItemService" UpdateMethod="UpdateProfileItem">
<SelectParameters>
<asp:Parameter Name="CategoryID" Type="Int32" />
</SelectParameters>
<UpdateParameters>
<asp:ControlParameter Name="IsSorting" ControlID="CheckBoxSort" PropertyName="Checked" />
</UpdateParameters>
</asp:ObjectDataSource>
Upvotes: 1
Views: 3971
Reputation: 21314
When using a CheckBox control with an Object Data Source, the value to pass to the wired up 'Update' method needs to be of type Boolean. I do this often, take a look to my code:
<UpdateParameters>
<asp:Parameter Name="IsAdminUser" Type="Boolean" />
<asp:Parameter Name="IsPowerUser" Type="Boolean" />
</UpdateParameters>
Now just to show you as well, here is how I am binding the CheckBox on the page with data from the 'Select':
<asp:CheckBox ID="chkIsAdmin" runat="server" Checked='<%# Bind("IsAdminUser") %>' />
This checkbox control happens to be within a GridView, and the GridView's datasource is the Object Data Source control, so that is where data is bound. No matter if you are using a GridView or any other control such as a plain checkbox box, you should be able to use the format above to get the checkbox bound and updated properly.
Upvotes: 3
Reputation: 1844
Have you tried to findout the Checkbox control ID from the HTML page rendered. Sometimes if you use master page it may change the controlId.
Upvotes: 0