I would apprecaite any assistance with this task..

SourceForm.aspx contains a databound gridview which I have added a checkbox column for multiple row selection. OnClick of a button I want to display any selected rows on another page, Target.aspx

So far I have successfully captured textbox input properites using PostBackUrl between the two, e.g.

        Enter your name:
        <asp:TextBox ID="_nameTextBox" runat="server" /><br />
        Enter your age:
        <asp:TextBox ID="_ageTextBox" runat="server" /><br />
        <asp:CheckBox ID="_marriedCheckBox" runat="server" Text="Married?" /><br />
        <asp:Button ID="_nextPageButton" runat="server" Text="Next page" PostBackUrl="Target.aspx"/>
        <asp:Label ID="LabelTest" runat="server" Text="Hello anyway"></asp:Label>


    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            MessageLabel.Text = String.Format("<h3>Hello there {0}, you are {1} years" + " old and {2} married! {3}</h3>", PreviousPage.Name, PreviousPage.Age, If(PreviousPage.Married, "", "not"), PreviousPage.Hello)
        End If

I have also been trying to adapt URL strings to do something similar, e.g.

Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        Response.Redirect("GridViewMultiSelect3Target.aspx?Subject=" & GridView1.DataKeys(GridView1.SelectedIndex).Values("SubjectDetails").ToString() & "&Start=" & GridView1.DataKeys(GridView1.SelectedIndex).Values("StartTime").ToString() & "&Finish=" & GridView1.DataKeys(GridView1.SelectedIndex).Values("FinishTime").ToString() & "&Extra=" & GridView1.DataKeys(GridView1.SelectedIndex).Values("ExtraFinishTime").ToString())
    End Sub


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.TextBox1.Text = Request.QueryString("Subject")
        Me.TextBox2.Text = Request.QueryString("Start")
        Me.TextBox3.Text = Request.QueryString("Finish")
        Me.TextBox3.Text = Request.QueryString("Extra")
    End Sub

Some examples I've tried to follow point towards using DataKey Rows of chkSelected but I'm totally unfamiliar with this and have failed on a few tutorials.

So, I've thrown this out for some experienced advice, and preferably a good working example


5 Years
Discussion Span
Last Post by __avd

Always try to write SSCCE that way you will find your issue & solution too.

Here is my SSCCE:

SourcePage.aspx markup : Add a GridView1 and a Button1

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
                        <asp:Label ID="Label1" runat="server" 
                            Text='<%# Eval("ID") %>'></asp:Label>
                        <asp:CheckBox ID="CheckBox1" runat="server" />
 <asp:Button ID="Button1" runat="server" Text="Button" />

SourcePage.aspx code behind (VB) : Handle the click handle of Button1 in which iterate the GridView.Rows collection, determine the checkbox status and depends upon the status of checkbox prepare the list (list of items - string, ints, objects). At the end of loop, use Session state to save/push the list so we may use this list from other page (Target.aspx).

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Dim Result = (From no In New Integer() 
                          {11, 22, 33, 44} Select New With {.ID = no}).ToList()
            GridView1.DataSource = Result
        End If
        AddHandler Button1.Click,
                   Sub(sa, ea)
                       Dim selectedItem As New List(Of Integer)
                       For Each row As GridViewRow In GridView1.Rows
                           If row.RowType = DataControlRowType.DataRow Then
                               If CType(row.FindControl("CheckBox1"), CheckBox).Checked Then
                                   Dim id = Integer.Parse(CType(row.FindControl("Label1"), Label).Text)
                               End If
                           End If
                       Session("selectedItem") = selectedItem
                   End Sub
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.