Retaining selected items after pagechange or sort

J

J

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
 

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,054
Latest member
TrimKetoBoost

Latest Threads

Top