By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,507 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,507 IT Pros & Developers. It's quick & easy.

ObjectDataSource Bind( ) on Template Column losing data on Sort

P: n/a
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.

Mar 23 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.