ObjectDataSource Bind( ) on Template Column losing data on Sort

Discussion in 'ASP .Net' started by GMartin, Mar 23, 2007.

  1. GMartin

    GMartin Guest

    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.
     
    GMartin, Mar 23, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,602
    mr2_93
    Oct 2, 2005
  2. Replies:
    1
    Views:
    3,854
    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=
    May 3, 2006
  3. Jodi
    Replies:
    0
    Views:
    157
  4. Navin
    Replies:
    1
    Views:
    704
    Ken Schaefer
    Sep 9, 2003
  5. Jason C
    Replies:
    4
    Views:
    688
    Morty Abzug
    Jun 26, 2012
Loading...

Share This Page