Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > registering events for dynamically declared DataGrids

Reply
Thread Tools

registering events for dynamically declared DataGrids

 
 
Faredoon Irani via .NET 247
Guest
Posts: n/a
 
      08-05-2004
Hi,

I have to display many DataGrids in one page, but at design-timeI do not know how many DataGrids there are going to be. So I amconstructing them in the code-behind. The problem here is, Ialso want a event-handler for the ItemCommand event of each ofthose DataGrids. For this, I am aware that just declaring theevent using:

DataGrid1.ItemCommand += newDataGridCommandEventHandler(DataGrid1_ItemComma nd);

is fine. but this doesn't always get fired in my case becausethis variable "DataGrid1" is one that is going to getinstantiated many times in a loop like this:

DataGrid1 = new System.Web.UI.WebControls.DataGrid();

The variable is a protected class member. This will result in alot of un-disposed DataGrid objects because I never call theDispose() method on any of them - If I do so, the DataGrid willnot get displayed at all! I was thinking of using a collectionclass to dump all the Datagrid objects and Clear the collectionon Page_Load (that is where I am constructing the DataGrids,binding the Data and so on ). But is that possible? the majorproblem here is of the ItemCommand event-handler not gettingcalled. I am checking for a "IsPostBack" in Page_Load andappropriately constructing the grids.

Help needed, please...
--------------------------------
From: Faredoon Irani

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>jeJnnd00PUCwYJw05pwXog==</Id>
 
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
Re: registering/re-registering ASP.NET 1.1.4322 with IIS Juan T. Llibre ASP .Net 2 12-16-2006 12:29 AM
declared or not declared ? JohnZing ASP .Net 3 02-05-2006 08:38 PM
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
Registering clientside events for a RadioButtonList Helen ASP .Net 2 09-30-2004 08:21 PM
Changing datagrids Headertexts /events in an dynamically created datagrid Anna Schmidt ASP .Net Web Controls 1 02-27-2004 07:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57