selecting multiple records in checkbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mirainc
    New Member
    • Jul 2008
    • 34

    selecting multiple records in checkbox

    hey all..

    i have a gridview with a checkbox in ItemTemplate..
    what i have already done is when i select any checkbox, it will direct me to another page.
    That other page contains a reminder letter in which i can just print it..

    But now i want to be able to select several checkbox and just print those letters..

    How can i achieve this?
    using VB.NET
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Perhaps you can add the link or whatever key value each entry is based off of to an array or list. Then add that list to a session variable. Then redirect to another page that loops through the array, and renders each of the "reminders" or whatever on a single page for you to print.

    That's probably what I'd do. Considering I haven't seen your code. It's kind of a vague question.

    Comment

    • mirainc
      New Member
      • Jul 2008
      • 34

      #3
      Originally posted by insertAlias
      Perhaps you can add the link or whatever key value each entry is based off of to an array or list. Then add that list to a session variable. Then redirect to another page that loops through the array, and renders each of the "reminders" or whatever on a single page for you to print.

      That's probably what I'd do. Considering I haven't seen your code. It's kind of a vague question.
      Code:
      //Destination page
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
              'AddressEcc labels
              Label10.Text = Request.QueryString("Name")
              Label11.Text = "Admission No: " + Request.QueryString("Adm_No")
              'Display the value of Hidden column in a label control
              Label12.Text = Request.QueryString("TermAdd1")
              Label13.Text = Request.QueryString("TermAdd2")
              Label14.Text = Request.QueryString("TermCountry") + " " + Request.QueryString("TermPostCo")
              Label27.Text = Request.QueryString("TermAdd3")
      Code:
      //Source page
      Protected Sub CheckBox1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
              Dim gvr As GridViewRow = DirectCast(DirectCast(sender, CheckBox).Parent.Parent, GridViewRow)
              Dim cb As CheckBox = DirectCast(sender, CheckBox)
              Dim row As GridViewRow = DirectCast(cb.NamingContainer, GridViewRow)
              If row IsNot Nothing Then
                  Dim key As String = AddressGridView.DataKeyNames(0)
                  Dim TermAdd1 As String = DirectCast(AddressGridView.DataKeys(row.RowIndex).Values("TermAdd1"), String)
                  Dim TermAdd2 As String = DirectCast(AddressGridView.DataKeys(row.RowIndex).Values("TermAdd2"), String)
                  Dim TermAdd3 As String = DirectCast(AddressGridView.DataKeys(row.RowIndex).Values("TermAdd3"), String)
                  Dim TermCountry As String = DirectCast(AddressGridView.DataKeys(row.RowIndex).Values("TermCountry"), String)
                  Dim TermPostCo As String = DirectCast(AddressGridView.DataKeys(row.RowIndex).Values("TermPostCo"), String)
      
                  Dim Adm_No As String = gvr.Cells(2).Text
                  Dim Name As String = gvr.Cells(3).Text
                  Response.Redirect("~\Reminder letter\ReminderLetter(ECC-BULK).aspx?Adm_No=" + Adm_No + "&Name=" + Name + "&TermAdd1=" + TermAdd1 + "&TermAdd2=" + TermAdd2 + "&TermCountry=" + TermCountry + "&TermPostCo=" + TermPostCo + "&TermAdd3=" + TermAdd3)
              End If
      
          End Sub
      can guide on using the array in VB.NET?

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Well, you might have to write another destination page. Can you get all the data again from a key value in the gridview? If you can, that makes this pretty easy. If not, it will be a little bit more work.

        It's going to take some changing. You can't do auto post back on your checkboxes. You need to add a button to click when you've selected the check boxes you want.

        Then, in that button's event:
        If you have some key data, like an id number or something, just use a List. Make sure you put
        Code:
        Imports System.Collections.Generic
        at the very top of the code. Then use a List:
        Code:
        Dim lst as List(of Int32)
        and loop through your gridveiw, adding the key value to the list each time.

        Then add the list to a session variable, and on your destination page, loop through it to build a sql statement to select the rows you need. You can use a repeater to display each row.

        Comment

        Working...