how do you reference a buttonTempleteColumn in a datagrid ?
Hi I'm trying to find out how you reference the button that's been clicked in a datagrid's buttonTempleteColumn ?
[128 byte] By [
Matrix.net] at [2007-11-11 9:57:03]

# 2 Re: how do you reference a buttonTempleteColumn in a datagrid ?
by Captions you mean the Text property of the button correct? I've never used Cases . So basically an example of what I would do would be :
If TypeOf e.CommandSource Is Button Then
Dim btnSource As Button = DirectCast(e.CommandSource, Button)
Select Case btnSource.Text
Case "Button1"
code here for this case
Case "Button2"
code here for this other case
End Select
End If
correct ?
# 3 Re: how do you reference a buttonTempleteColumn in a datagrid ?
Correct. If you simply need a reference to the button that fired the event, then you only need this line:
Dim btnSource As Button = DirectCast(e.CommandSource, Button)
' Now use btnSource as you would any other button
# 5 Re: how do you reference a buttonTempleteColumn in a datagrid ?
Only problem I'm having now though is that the code that needs to execute in either case needs to know what the selected row is and so I'm getting objects not set to an instance error messages when I click them . I suppose somehow I need to execute the SELECT command in the code for both cases but dont know how.
OR
Maybe I dont have to know what is selected, I just need to know the rowIndex that the button lies on. Again I dont know how you would do that.