T
The Alchemist
I am having a problem with a dynamically-generated Datagrid. It is
important to point out that this problem does not exist with a
design-time created Datagrid, but only with a dynamically generated
Datagrid in a Web Custom Control (WCC) :
The datagrid has LinkButton Column which has a select LinkButton for
each row. When this button is clicked, the Datagrid raises its
'ItemCommand' event which captures the information for that row and
sends it to a event handler method. The problem is that this method is
never getting called. It seems logical to assume that there is
something wrong with the event-wiring of the datagrid. The signature
of the event-handler is:
Private Sub DataGrid1_SelectedIndexChanged(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dg.ItemCommand
(dg is the name of the datagrid). The 'Handles' keyword in VB.Net is
supposed to wire the event to the handler but that is not happening.
So I tried to manually add the handler to the event with the following
line of code in the CreateChildControls method of the WCC using the
line:
AddHandler dg.ItemCommand, AddressOf Me.DataGrid1_SelectedIndexChanged
That does not work either. The datagrid loads up just fine, and on
selecting a row it does a PostBack and hits the OnLoad event but never
hits the event-handler method.
Why is this event not being wired to the handler? Or might there be
some other problem?
Thanks in advance for any help.
BZ
important to point out that this problem does not exist with a
design-time created Datagrid, but only with a dynamically generated
Datagrid in a Web Custom Control (WCC) :
The datagrid has LinkButton Column which has a select LinkButton for
each row. When this button is clicked, the Datagrid raises its
'ItemCommand' event which captures the information for that row and
sends it to a event handler method. The problem is that this method is
never getting called. It seems logical to assume that there is
something wrong with the event-wiring of the datagrid. The signature
of the event-handler is:
Private Sub DataGrid1_SelectedIndexChanged(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dg.ItemCommand
(dg is the name of the datagrid). The 'Handles' keyword in VB.Net is
supposed to wire the event to the handler but that is not happening.
So I tried to manually add the handler to the event with the following
line of code in the CreateChildControls method of the WCC using the
line:
AddHandler dg.ItemCommand, AddressOf Me.DataGrid1_SelectedIndexChanged
That does not work either. The datagrid loads up just fine, and on
selecting a row it does a PostBack and hits the OnLoad event but never
hits the event-handler method.
Why is this event not being wired to the handler? Or might there be
some other problem?
Thanks in advance for any help.
BZ