I have a gridview in a webform and I would like to know how I can select a single cell anywhere in that gridview using a mouse click.
The selected cell's background colour then changes to a specific colour and a textbox on the form displays the row number and column number which I will pass as parameters to a stored procedure.
When a subsequent cell is selected the last selected cell reverts back to it's original colour and the new cell's background colour is changed and the textbox updates to the new cell's row number and column number.
The closest I've got so far is selecting a whole row, but even this only affects the first cell of the row background-wise. The underline affects all cells in the row.
Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
For Each row As GridViewRow In gvProgressGrid.Rows
If row.RowType = DataControlRowType.DataRow Then
row.Attributes("onclick") = "this.style.cursor='pointer';this.style.ine';this.style.backgroundColor ='#EEE'"
End If
Next
MyBase.Render(writer)
End Sub