Hi Mudassar, ALL,
I originally, I used most of the code from this link:
http://www.aspsnippets.com/Articles/Implement-check-all-checkbox-functionality-in-ASP.Net-GridView-control-using-JavaScript.aspx
to allow our users the ability to check one or more checkboxes, grab data from the checked boxes and append them into a url.
This works a treat.
Here is code snippet.
Protected Sub btnGetChecked_Click(ByVal sender As Object, ByVal e As EventArgs)
Response.AddHeader("content-disposition", "attachment; filename=Parcels.pdf")
HttpContext.Current.Response.ContentType = "application/pdf"
Dim doc As New PdfDocument()
Dim baseLINK As String = _
"http:default.html?mode=print&o=N&yu=0.4"
For Each r As GridViewRow In GridView1.Rows
If CType(r.Cells(0).FindControl("CheckBox1"), CheckBox).Checked Then
Dim link As String = baseLINK & "&gen=" & r.Cells(1).Text
HtmlToPdf.ConvertUrl(link, doc)
End If
Next
doc.Save(HttpContext.Current.Response.OutputStream)
End Sub
Above code was based on link above.
Then our users were having problem preserving checked boxes when navigating to other pages since we are using paging.
Then I was fortunate to your article for preserving checkboxes from the link below:
http://www.aspsnippets.com/Articles/Preserving-state-of-Checkboxes-while-paging-in-ASP.Net-GridView-Control.aspx
Now, my code above no longer works.
Does anyone know how to modify it to use new code from this link?
My guess is that it needs to be modified to work with the following code but I am not sure what to change. Any help is greatly appreciated:
For i As Integer = 0 To GridView1.Rows.Count - 1
If GridView1.Rows(i).RowType = DataControlRowType.DataRow Then
Dim chk As CheckBox = _
DirectCast(GridView1.Rows(i).Cells(0) _
.FindControl("CheckBox1"), CheckBox)
CheckBoxIndex = GridView1.PageSize * GridView1.PageIndex + (i + 1)
If chk.Checked Then
If CheckBoxArray.IndexOf(CheckBoxIndex) = -1 And _
Not CheckAllWasChecked Then
CheckBoxArray.Add(CheckBoxIndex)
End If
Else
If CheckBoxArray.IndexOf(CheckBoxIndex) <> -1 Or _
CheckAllWasChecked Then
CheckBoxArray.Remove(CheckBoxIndex)
End If
End If
End If
Next
By the way, fantastic articles.