J
John McCarthy
Question:
I would like to add a ButtonColumn
to a datagrid on the fly .....
Thus far ....
(1) Adding the button works ....
(2) Trying to hook up an event
handler does not work ....
Conceptually, I must be missing
a big point .... (guessing)
Neither Scott Mitchell nor Waltham,
or Payne, or a whole bunch
of other people - in their books, go into this ...
and perhaps its because
I should not be attempting
to do this .....
i.e. dumb approach ?
My purpose in all this is to
get as much as possible off
the HTML page and onto the
code behind page ...
i.e. the myriad properties
and so on .....
I have googlized this to death
but cannot find an example
of a grid with the same minimal
attributes(?) as below ...
Any help or direction would
be very much appreciated ....
---------------------
HTML Page
---------------------
<ASPATAGRID
id="dg1"
runat="server">
</ASPATAGRID>
---------------------
Code Behind
---------------------
Some Sub
'--------------------------------
' Add Button Column
'--------------------------------
Dim oBut As New ButtonColumn
oBut.ButtonType = ButtonColumnType.LinkButton
oBut.Text = "Select"
oBut.CommandName = "Select"
dg1.Columns.Add(oBut)
'Nada happens
AddHandler dg1.SelectedIndexChanged, AddressOf my_SelectedIndexChanged
Private Sub my_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dg1.SelectedIndexChanged
Dim s as string = "See Spot run ...."
End Sub
Note:
I have no problem adding a normal button to
a page and adding a handler ......
Thanks in advance for any guidence ....
regards,
John McCarthy
I would like to add a ButtonColumn
to a datagrid on the fly .....
Thus far ....
(1) Adding the button works ....
(2) Trying to hook up an event
handler does not work ....
Conceptually, I must be missing
a big point .... (guessing)
Neither Scott Mitchell nor Waltham,
or Payne, or a whole bunch
of other people - in their books, go into this ...
and perhaps its because
I should not be attempting
to do this .....
i.e. dumb approach ?
My purpose in all this is to
get as much as possible off
the HTML page and onto the
code behind page ...
i.e. the myriad properties
and so on .....
I have googlized this to death
but cannot find an example
of a grid with the same minimal
attributes(?) as below ...
Any help or direction would
be very much appreciated ....
---------------------
HTML Page
---------------------
<ASPATAGRID
id="dg1"
runat="server">
</ASPATAGRID>
---------------------
Code Behind
---------------------
Some Sub
'--------------------------------
' Add Button Column
'--------------------------------
Dim oBut As New ButtonColumn
oBut.ButtonType = ButtonColumnType.LinkButton
oBut.Text = "Select"
oBut.CommandName = "Select"
dg1.Columns.Add(oBut)
'Nada happens
AddHandler dg1.SelectedIndexChanged, AddressOf my_SelectedIndexChanged
Private Sub my_SelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs) Handles dg1.SelectedIndexChanged
Dim s as string = "See Spot run ...."
End Sub
Note:
I have no problem adding a normal button to
a page and adding a handler ......
Thanks in advance for any guidence ....
regards,
John McCarthy