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>
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:
Now just to show you as well, here is how I am binding the CheckBox on the page with data from the ‘Select’:
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.