bruceypatel123
Member
- Joined
- Oct 19, 2010
- Messages
- 5
- Programming Experience
- Beginner
I have created two gridviews. GridView1 contains the data of the products while GridView2 should output the products which have been selected through a check box. I don't know how to output the rows from GridView1to GridView2 after clicking on a button (AddSelectedProducts), can you help me?
Below is the current VB.Net coding
Protected Sub AddSelectedProducts_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddSelectedProducts.Click
Dim chk As CheckBox
MessageLabel.Text = String.Empty
For Each rowItem As GridViewRow In GridView1.Rows
chk = CType(rowItem.Cells(0).FindControl("ProductSelector"), CheckBox)
If chk.Checked = True Then
MessageLabel.Text &= rowItem.Cells(2).Text & " is added into your Shopping Basket<br/>"
End If
Next
End Sub
I like to say that both gridviews have been made by dragging it and putting it on the web form. SqlDatasource1 is linked to gridView1 and SqlDatasource2 is linked to gridView 2. The fields in GridView1 is the checkbox field, ProductID, ProductName, Description, Price, Category, Manufacturer and Image. In GridView2 it is the same except there is no checkbox field or Description field.
Below is the current VB.Net coding
Protected Sub AddSelectedProducts_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles AddSelectedProducts.Click
Dim chk As CheckBox
MessageLabel.Text = String.Empty
For Each rowItem As GridViewRow In GridView1.Rows
chk = CType(rowItem.Cells(0).FindControl("ProductSelector"), CheckBox)
If chk.Checked = True Then
MessageLabel.Text &= rowItem.Cells(2).Text & " is added into your Shopping Basket<br/>"
End If
Next
End Sub
I like to say that both gridviews have been made by dragging it and putting it on the web form. SqlDatasource1 is linked to gridView1 and SqlDatasource2 is linked to gridView 2. The fields in GridView1 is the checkbox field, ProductID, ProductName, Description, Price, Category, Manufacturer and Image. In GridView2 it is the same except there is no checkbox field or Description field.