Retaining selected items after pagechange or sort

Discussion in 'ASP .Net Datagrid Control' started by J, Aug 19, 2003.

  1. J

    J Guest

    Hi,

    I've created a datagrid which has 4 columns, a 'checkbox' column, ID, Name
    and and image.

    My HTML looks like...

    <asp:DataGrid id="DataGrid1" runat="server" AllowSorting="True"
    AutoGenerateColumns="False" PageSize="3">
    <Columns>
    <asp:BoundColumn></asp:BoundColumn>
    <asp:BoundColumn DataField="distID" SortExpression="distID"
    HeaderText="DistID"></asp:BoundColumn>
    <asp:BoundColumn DataField="distName" SortExpression="distName"
    HeaderText="DistName"></asp:BoundColumn>
    <asp:BoundColumn DataField="distributorLevel"
    SortExpression="distributorLevel" HeaderText="Level"></asp:BoundColumn>
    </Columns>
    <PagerStyle Mode="NumericPages"></PagerStyle>
    </asp:DataGrid>

    My VB.ASP code looks like...

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DataGridItemEventArgs) Handles
    DataGrid1.ItemDataBound

    If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType =
    ListItemType.Item Then

    Dim distributionLevelImage As New HtmlImage()

    Dim chooseName As New CheckBox()

    chooseName.AutoPostBack = True

    chooseName.EnableViewState = True

    distributionLevelImage.Src = "images/distributionLevelImages/Level" +
    e.Item.Cells(3).Text + ".Gif"

    e.Item.Cells(3).Controls.Add(distributionLevelImage)

    e.Item.Cells(0).Controls.Add(chooseName)

    End If

    End Sub



    What I'm trying to achive is to allow the user to choose a selection, using
    the check boxes, but when they sort, or change page, those items that they
    have previously selected are lost!

    Does anyone have any pointers, websites etc, for me to understand how to do
    what I want.

    TIA
     
    J, Aug 19, 2003
    #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. Bart Van Hemelen
    Replies:
    2
    Views:
    4,717
    Bart Van Hemelen
    Sep 4, 2006
  2. Iain
    Replies:
    3
    Views:
    969
  3. Jeremy Jones
    Replies:
    4
    Views:
    1,365
    Jeremy Jones
    Dec 14, 2006
  4. Constantly Distracted
    Replies:
    0
    Views:
    298
    Constantly Distracted
    Jun 14, 2008
  5. Navin
    Replies:
    1
    Views:
    765
    Ken Schaefer
    Sep 9, 2003
Loading...

Share This Page