ObjectDataSource Bind( ) on Template Column losing data on Sort

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.

.



Relevant Pages

  • Re: sorting a linked list
    ... and the other members of the newsgroup: would it not be more efficient to ... % sort_list/2 identifies the head of the sorted list and sorts ... regard to choice-points and back-tracking. ...
    (comp.lang.prolog)
  • Re: How to programmatically access ObjectDataSource values
    ... You can access the ObjectDataSource's SelectParameters from anywhere on the page and change the DefaultValue to anything you'd like. ... you can handle the ObjectDataSource's Selecting event and then modify the parameters for that one select by adding or chaninging the ObjectDataSourceSelectingEventArgs's InputParameters. ... ObjectDataSource in our project. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: SelectCountMethod error - looking for parameters?
    ... The ObjectDataSource will search for a SelectCount method with the ... parameters specified in the SelectParameters collection. ... Anyway, in your case, you are using paging and sorting so the ... declaration was generated when I ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: convert typedef struct from C++ to VB
    ... Ken Halter schrieb: ... Additionally VB sorts the members of a struct after their data ...
    (microsoft.public.vb.winapi)
  • Re: SelectCountMethod error - looking for parameters?
    ... As far as I can tell you, yes, they both look to the SelectParameters, ... attributes to the methods that will be consumed by the ObjectDataSource ... miky wrote: ... declaration was generated when I ...
    (microsoft.public.dotnet.framework.aspnet)