I have a grid view consisting of options for a computer ([x] = a tick box)
Code Description Price
2323 Mouse £4.00 [x]
4555 Keyboard £8.00 [x]
9898 Memory £10.49 [x]
54647 Cable £10.00 [x]
where the user can tick the items they want then click on the 'add to cart' button.
Setting DataKeyNames="txtProductCode" in the GridView enables me to retrieve the code of the item ticked using
Dim sOptionCode As String
Dim cb As CheckBox
For Each row As GridViewRow In gvOptionsList.Rows
cb = DirectCast(row.FindControl("chkBox"), CheckBox)
If cb IsNot Nothing AndAlso cb.Checked Then
sOptionCode = gvOptionsList.DataKeys(row.RowIndex).Value
lblTest.Text += sOptionCode + ","
End If
Next
and I can retrieve the information from the tickbox using FindControl. I can't figure how I obtain the Description and Price from the gridview though (these are just bound fields)
<asp:BoundField DataField="txtDescription" HeaderText="Description" SortExpression="txtDescription" />
Can anyone advise? is it possible?
Thanks
Andy
Code Description Price
2323 Mouse £4.00 [x]
4555 Keyboard £8.00 [x]
9898 Memory £10.49 [x]
54647 Cable £10.00 [x]
where the user can tick the items they want then click on the 'add to cart' button.
Setting DataKeyNames="txtProductCode" in the GridView enables me to retrieve the code of the item ticked using
Dim sOptionCode As String
Dim cb As CheckBox
For Each row As GridViewRow In gvOptionsList.Rows
cb = DirectCast(row.FindControl("chkBox"), CheckBox)
If cb IsNot Nothing AndAlso cb.Checked Then
sOptionCode = gvOptionsList.DataKeys(row.RowIndex).Value
lblTest.Text += sOptionCode + ","
End If
Next
and I can retrieve the information from the tickbox using FindControl. I can't figure how I obtain the Description and Price from the gridview though (these are just bound fields)
<asp:BoundField DataField="txtDescription" HeaderText="Description" SortExpression="txtDescription" />
Can anyone advise? is it possible?
Thanks
Andy