Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Need help with ItemCommand event

Reply
Thread Tools

Need help with ItemCommand event

 
 
Gilles T.
Guest
Posts: n/a
 
      01-05-2004
I have on the same page this code:
<script language="VB" runat="server">
...
...
Private Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
subDatagrid.ItemCommand
...
End Sub
...
...
</script>
<ASPataGrid id="subDatagrid" runat="server"
AllowSorting="False"
...
...

I have this error:
Handles clause requires a WithEvents variable
at this line: Private Sub subDatagrid_ItemCommand(ByVal source As Object,
ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
subDatagrid.ItemCommand


If I add this line in top:
Protected WithEvents subDatagrid As System.Web.UI.WebControls.DataGrid

I have this error:
'subDatagrid' is already declared as 'Protected Dim subDatagrid As
System.Web.UI.WebControls.DataGrid' in this class.

What is the problem?
Can you help me please?

Thanks


 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      01-05-2004
Hi,

as you use inline code put it this way:

Code:
Protected Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs)
...
End Sub
(i.e no handles clause at all).

Then for the DataGrid:
Code:
<asp:DataGrid id="subDatagrid" runat="server"
OnItemCommand="subDatagrid_ItemCommand" ...>
...
</asp:DataGrid>
i.e you specify the event handler method declaratively in aspx with
On<EventName> attribute.

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Gilles T." <(E-Mail Removed)> wrote in message
news:8ejKb.4853778$(E-Mail Removed)...
> I have on the same page this code:
> <script language="VB" runat="server">
> ...
> ...
> Private Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e As
> System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> subDatagrid.ItemCommand
> ...
> End Sub
> ...
> ...
> </script>
> <ASPataGrid id="subDatagrid" runat="server"
> AllowSorting="False"
> ...
> ...
>
> I have this error:
> Handles clause requires a WithEvents variable
> at this line: Private Sub subDatagrid_ItemCommand(ByVal source As Object,
> ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> subDatagrid.ItemCommand
>
>
> If I add this line in top:
> Protected WithEvents subDatagrid As System.Web.UI.WebControls.DataGrid
>
> I have this error:
> 'subDatagrid' is already declared as 'Protected Dim subDatagrid As
> System.Web.UI.WebControls.DataGrid' in this class.
>
> What is the problem?
> Can you help me please?
>
> Thanks
>
>



 
Reply With Quote
 
 
 
 
Gilles T.
Guest
Posts: n/a
 
      01-05-2004
Thanks Teemu!


"Teemu Keiski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> as you use inline code put it this way:
>
>
Code:
> Protected Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e As
> System.Web.UI.WebControls.DataGridCommandEventArgs)
>      ...
>  End Sub
>
>
> (i.e no handles clause at all).
>
> Then for the DataGrid:
>
Code:
> <asp:DataGrid id="subDatagrid" runat="server"
> OnItemCommand="subDatagrid_ItemCommand" ...>
> ..
> </asp:DataGrid>
>
>
> i.e you specify the event handler method declaratively in aspx with
> On<EventName> attribute.
>
> --
> Teemu Keiski
> MCP, Microsoft MVP (ASP.NET), AspInsiders member
> ASP.NET Forum Moderator, AspAlliance Columnist
>
> "Gilles T." <(E-Mail Removed)> wrote in message
> news:8ejKb.4853778$(E-Mail Removed)...
> > I have on the same page this code:
> > <script language="VB" runat="server">
> > ...
> > ...
> > Private Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e

As
> > System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> > subDatagrid.ItemCommand
> > ...
> > End Sub
> > ...
> > ...
> > </script>
> > <ASPataGrid id="subDatagrid" runat="server"
> > AllowSorting="False"
> > ...
> > ...
> >
> > I have this error:
> > Handles clause requires a WithEvents variable
> > at this line: Private Sub subDatagrid_ItemCommand(ByVal source As

Object,
> > ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
> > subDatagrid.ItemCommand
> >
> >
> > If I add this line in top:
> > Protected WithEvents subDatagrid As

System.Web.UI.WebControls.DataGrid
> >
> > I have this error:
> > 'subDatagrid' is already declared as 'Protected Dim subDatagrid As
> > System.Web.UI.WebControls.DataGrid' in this class.
> >
> > What is the problem?
> > Can you help me please?
> >
> > Thanks
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Bubbling and the ItemCommand Event Nathan Sokalski ASP .Net Web Controls 0 05-29-2006 07:16 AM
Event Bubbling and the ItemCommand Event Nathan Sokalski ASP .Net 0 05-29-2006 07:16 AM
Event Bubbling and the ItemCommand Event Nathan Sokalski ASP .Net Datagrid Control 0 05-29-2006 07:16 AM
Need help with ItemCommand event Gilles T. ASP .Net 2 01-05-2004 08:17 PM
help with ItemCommand event Brian Smith ASP .Net Datagrid Control 0 07-14-2003 01:42 PM



Advertisments