Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identifying control client side in Gridview

Status
Not open for further replies.

AndyH1

Programmer
Jan 11, 2004
350
GB
I have a grid view consisting of options for a computer ([x] = a tick box)

Code Description Price Quantity
2323 Mouse £4.00 [1] [x]
4555 Keyboard £8.00 [1] [x]
9898 Memory £10.49 [2] [x]
54647 Cable £10.00 [1] [x]
where the user can tick the items they want then click on the 'add to cart' button.

Iv'e added javascript on the quantity text boxes so that when the user clicks on them it clears the field

ie
Protected Sub gvOptionsList_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvOptionsList.DataBound
For Each gvr As GridViewRow In gvOptionsList.Rows
' Set each quantity text box with a javascript to clear if if clicked
Dim tb As TextBox = CType(gvr.FindControl("Quantity"), TextBox)
tb.Attributes.Add("onfocus", "this.value='';")
'Add the CheckBox's ID to the client-side CheckBoxIDs array
' tb.ClientID
Next
End Sub

This works fine. The next step I want to do though is that all the quantity boxes are disabled, but when the user ticks a checkbox the quantity box next to the box is enabled. However I don't know how to get the appropriate quantity's box clientside id related to the checkbox in order to add javascript to the checkbox to do this, so can't figure out how to do this. Assume doing this in javascript is the best way? Can anyone advise on how I get the value to use in the javascript beside.

Thanks in advance - and thanks for the previous help a few days ago on the other gridview problem.

Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top