473,734 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ItemCommand of Datagrid within a user control will not fire.

I have a user control contain one datagrid. this datagrid contains one
button column with commandName "Review", I have event handler
datagrid_ItemCo mmand to handle this event and also wired the event when
initial. but when I put this user control in a web form, click the
review link(it is linkbutton) will not fire the event. Any one have any
idea what is the problem. Thanks a lot!
Nov 17 '05 #1
3 2503
I would check the InitializeCompo nent method to see if the event handler for
this event is included.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Li Zhang" <zh********@gma il.com> wrote in message
news:u2******** ******@TK2MSFTN GP15.phx.gbl...
I have a user control contain one datagrid. this datagrid contains one
button column with commandName "Review", I have event handler
datagrid_ItemCo mmand to handle this event and also wired the event when
initial. but when I put this user control in a web form, click the
review link(it is linkbutton) will not fire the event. Any one have any
idea what is the problem. Thanks a lot!
Nov 17 '05 #2
Thanks David for your quick reply. I checked the InitializeCompo nent
method already. Here is the InitializeCompo nent method:

private void InitializeCompo nent()
{
this.imageDataG rid.ItemCommand += new
System.Web.UI.W ebControls.Data GridCommandEven tHandler(this.i mageDataGrid_It emCommand);
this.Load += new System.EventHan dler(this.Page_ Load);
}

And I have my event handler:
private void imageDataGrid_I temCommand(obje ct sender,
DataGridCommand EventArgs e)
{
//some code here.
}

I don't know what is the problem. Thanks.

David Lloyd wrote:
I would check the InitializeCompo nent method to see if the event handler for
this event is included.


Nov 17 '05 #3
Li Zhang wrote:
Thanks David for your quick reply. I checked the InitializeCompo nent
method already. Here is the InitializeCompo nent method:

private void InitializeCompo nent()
{
this.imageDataG rid.ItemCommand += new
System.Web.UI.W ebControls.Data GridCommandEven tHandler(this.i mageDataGrid_It emCommand);

this.Load += new System.EventHan dler(this.Page_ Load);
}

And I have my event handler:
private void imageDataGrid_I temCommand(obje ct sender,
DataGridCommand EventArgs e)
{
//some code here.
}

I don't know what is the problem. Thanks.

David Lloyd wrote:
I would check the InitializeCompo nent method to see if the event
handler for
this event is included.


I found my problem. I made a very stupid mistake. when page postback the
user control did not load at all. I should load this control in
Page_Load event not in an other event handler function. Thanks guys!
Nov 17 '05 #4

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

Similar topics

0
1405
by: Daniel Armstrong | last post by:
Hello, I have a usercontrol that I have built that has a single generic datagrid. When setting up the inital properties I build the template columns for the datagrid dynamically so it can display as readonly or readwrite. The readwrite displays link buttons for edit, update, cancel and delete buttons. When I click on a edit link button the page using the usercontrol will begin it's page load event and then the usercontrol page load...
4
2003
by: Steven | last post by:
Hi there, I am having a weird problem. I have a datagrid with both an ItemCommand and a SortCommand. It was working fine until a day ago. Now, whenever I click a column to fire the SortCommand, the ItemCommand gets fired instead. In the debugger, e.CommandName is equal to "Sort", even though it is being handled by the ItemCommand event. If I remove the ItemCommand event handler, it works fine, but as soon as I put it back in the...
2
12012
by: Stan | last post by:
I cannot make the link buttons fire ItemCommand from repeater control. Here is the code: <asp:repeater id=rptLetters runat="server"> <itemtemplate> <asp:linkbutton id="lnkLetter" runat="server" commandname="Filter" CommandArgument='<%#
0
1291
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 fine if I add the controls at design time in the HTML, but does not seem to catch when I add the control dynamically in the code behind. The datagrid renders just fine, just no ItemCommand event... I have included some code snipplets below. Any...
0
1148
by: Mark Kelly | last post by:
(originally posted on framework.aspnet.datagridcontrol) Hi, I don't seem to be able to get a imagebutton (within a template column) to fire an itemcommand event when clicked. Looking through this NG, it seems like the same problem has been raised many times, except in most cases the problem occurs as the datagrid's databind method is being called on Postback - something that definately isn't happening in my code. I also have a standard...
3
5009
by: sri_san | last post by:
Hello Group, I use a datagrid with a linkbutton to delete the selected row. Added javascript confirm dialogue box in itembound event. The itemCommand event does not seem to fire when I debug the application. Any ideas? Code outline below: <asp:datagrid id="dbgrdCandidate_List" ForeColor="Black" runat="server"
2
3375
by: Deepesh | last post by:
Good day, I have a specific case of the DataGrid in my solution which is causing the ItemCommand Event Not Firing. So I'm creating a "Skinnable" set of controls. I seperate the actual ASCX file and .CS file. When I initialize my .CS file, in that code there is a method that goes: Page.LoadControl(FILENAME) Which associates a .ascx file with my .CS file, allowing me to plug in any
4
4161
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 any answers?? Regards,
1
3961
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 DatalistItemTemplate : ITemplate { public void InstantiateIn(Control container)
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

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.