jeudi 14 janvier 2016

GridView Checked Rows Values VB asp.net

I have GridView named GridViewTest and the first column in the GridView is a templatefield checkbox named CheckBox1. Im able to loop through all the rows that the GridView contains and display the value in a label named Label2. The issue i'm having is, I only want the rows that are checked to be displayed in the Label2. Can anyone help me?

Protected Sub btnDisplay_Click(sender As Object, e As EventArgs) Handles btnDisplay.Click

   Dim str As String = ""
   For i As Integer = 0 To GridViewTest.Rows.Count - 1
       str = (str + GridViewTest.Rows(i).Cells(0).Text & Convert.ToString(" >> ")) + GridViewTest.Rows(i).Cells(1).Text + " >> " + >GridViewTest.Rows(i).Cells(2).Text + "<br/>"
   Next

   Label2.Text = str

End Sub

PS: This is VB ASP.NET




Aucun commentaire:

Enregistrer un commentaire