ObjectDataSource Bind( ) on Template Column losing data on Sort

G

GMartin

I have a pop-up form with a three columned Grid that has checkboxes in
a Template Column in the first/left-most column. (The form is to
allow users to select "Members" of a group, where they check or clear
the boxes next to the potential members they want to add or remove.)

The Object Data Source is as follows...
<asp:ObjectDataSource ID="odsMembers" runat="server"
SelectMethod="GetGroupMembersSelectList"
TypeName="MyDataAccessLayer.MyObject">
<SelectParameters>
<asp:ControlParameter ControlID="hdnGroupSeqNo"
DefaultValue="" Name="GroupSeqNo"
PropertyName="Value" Type="Int32" />
<asp:ControlParameter ControlID="hdnGroupListName"
Name="ListName" PropertyName="Value"
Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>

The binding to the Grid is set up like this...
<asp:GridView ID="grdGroupMembers"
runat="server" AllowSorting="True" AutoGenerateColumns="False"
Width="97%" DataSourceID="odsMembers" DataKeyNames="MemberSeqNo">
<Columns>
<asp:TemplateField
SortExpression="Selected" >
<ItemStyle
HorizontalAlign="Center" Width="5%" />
<HeaderStyle
HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox
ID="chkSelect" runat="server" Checked=<%# Bind("SELECTED")%> />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField
DataField="MemberID" HeaderText="Member" SortExpression="MemberID">
<ItemStyle Width="35%" />
</asp:BoundField>
<asp:BoundField
DataField="MemberDescription" HeaderText="Description"
SortExpression="MemberDescription">
<ItemStyle Width="60%" />
</asp:BoundField>
</Columns>
</asp:GridView>

The ObjectDataSource calls my class ok, and returns a Typed DataSet
with MemberSeqNo, MemberID, MemberDescription, and Selected that it
loads correctly to the GridView.populating the CheckBoxes. But if a
user Selects/Deselects checkmarks and then Sorts (which is likely
because the List of potential members is long) their selections are
lost, and they're hating life. ...It sorts, and returns

I either need to...
1. Have the ObjectDataSource Update just Prior to it sorting.
Or....
2. Bind the Template Column "correctly?" to the ObjectDataSource so
the values are persisted/saved correctly.

The GridView's Sorting Events aren't being triggered when bound to the
ObjectDataSource, so I can't catch it there. And the ObjectDataSource
doesn't have a Sort Event that I could find, so Option 1 is looking
unlikely.

Am I binding this wrong to work with 2-Way binding? Is there anything
anyone sees that it looks like I may be doing wrong? Does, or can the
Sort routine be set to run an Update first?

Your help is much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top