473,388 Members | 1,346 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Need help with ItemCommand event

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>
<ASP:DataGrid 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
Nov 18 '05 #1
2 1508
Hi,

as you use inline code put it this way:

Expand|Select|Wrap|Line Numbers
  1. Protected Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e As
  2. System.Web.UI.WebControls.DataGridCommandEventArgs)
  3. ...
  4. End Sub
  5.  
(i.e no handles clause at all).

Then for the DataGrid:
Expand|Select|Wrap|Line Numbers
  1. <asp:DataGrid id="subDatagrid" runat="server"
  2. OnItemCommand="subDatagrid_ItemCommand" ...>
  3. ...
  4. </asp:DataGrid>
  5.  
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." <gi************@hotmail.com> wrote in message
news:8e*********************@news.easynews.com...
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>
<ASP:DataGrid 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

Nov 18 '05 #2
Thanks Teemu!
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:u3*************@TK2MSFTNGP11.phx.gbl...
Hi,

as you use inline code put it this way:

Expand|Select|Wrap|Line Numbers
  1.  Protected Sub subDatagrid_ItemCommand(ByVal source As Object, ByVal e As
  2.  System.Web.UI.WebControls.DataGridCommandEventArgs)
  3.       ...
  4.   End Sub
  5.  

(i.e no handles clause at all).

Then for the DataGrid:
Expand|Select|Wrap|Line Numbers
  1.  <asp:DataGrid id="subDatagrid" runat="server"
  2.  OnItemCommand="subDatagrid_ItemCommand" ...>
  3.  ..
  4.  </asp:DataGrid>
  5.  

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." <gi************@hotmail.com> wrote in message
news:8e*********************@news.easynews.com...
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>
<ASP:DataGrid 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


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: anon | last post by:
I am having a hard time with makeing what I am trying to do work. I am making a questionaire web app. I have a custom control that has a label and 5 radio buttons. My problem is that each...
0
by: Solomon Shaffer | last post by:
I am trying to add some link buttons to a datagrid template column at runtime and trying to wire these buttons up to the ItemCommand event (or any event when clicked!). The ItemCommand event works...
2
by: Matthew | last post by:
I have a DataGrid nested within a DataList. The DataGrid generates LinkButtons with specific CommandName values. I cannot figure out how to trap this event. I need to know which DataGrid...
0
by: Patrik Persson | last post by:
Hello all I have got a problem with a nested repeater and the ItemCommand Event. I am adding handler for the ItemCommand and ItemBound. The ItemBound works perfect but I cant seem to get the...
3
by: Joel Daniels | last post by:
Hello, I am trying to determine the proper way to access the underlying data row for a Repeater item in the ItemCommand event. In the page load event, I bind the Repeater data source to a...
4
by: Antonio Carpentieri | last post by:
Hi all, in my previous post I've wrong typed some tems.. this is the corrected post. in a aspx page I have a repeater like this: <asp:repeater id=repeaterResults runat="server"...
2
by: Curt_C [MVP] | last post by:
I've got a Repeater and within it a LinkButton. The LinkButton has an CommandName="Test" In the Repeater's ItemCommand event I want to check for this command name but the problem I'm having is...
4
by: EvelynAnd Ethan | last post by:
Hi, ItemCommand event not firing from a dynamic user control ,WHERE A DATAGRID HAS BUTTON,when i click on the linkbutton first time the itemcommand event doesnt fire,second time event fires up ...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.