Datagrid events dont fire

I have created a datagrid dynamically,the grid displays perfect...except that events dont fire. First time when the page loads ItemCreated and ItemDataBound events dont fire, When I click on any sort expession ,now I could see(using brakepoints) the events the firing..but here also after the code is executed neither sorting in the header column is performed nor totals are displyed in the footer. I tried almost everything ..like placing the event handlers,CreateGrid method in IntializeComponent() and everything I could find on net.Can anybody pls help??
kpankaj9Asked:
Who is Participating?
 
nauman_ahmedConnect With a Mentor Commented:
kpankaj9:

Creating the datagrid at runtime require some additional steps. The article that I have posted has some info. Please also take a loo at the following as it describes what you need to do in order to enable events for controls that are added at runtime:

Create Controls At Runtime
http://www.developerfusion.co.uk/show/4393/

--Nauman.
0
 
nauman_ahmedCommented:
Check the following article:

Creating DataGrid BoundColumn ButtonColumn HyperLinkColumn at Runtime in Asp.net
http://www.codeproject.com/useritems/datagridcloumns.asp

--Nauman.
0
 
RejojohnyCommented:
Can I ask what might be reason for dynamically creating a datagrid? if the grid needs to be shown conditionally, you can always use the "visible" property of the grid ..

dynamic controls are not so easy to work with .. also note that dynamic controls are NOT automatically created for every postback and so you will have to keep a track whether the datagrid was created in the previous postback and create it again in page "LOAD" or "INIT" event ..

Rejo
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
kpankaj9Author Commented:
Can anybody pls help, am I missing any page specific property or page level setting,I even created the same grid with nested grids but still having the exact same problem??Can any expert out thr help me with this as it is holding me up from moving further.
0
 
kpankaj9Author Commented:
Hi Rejojohny
I created the grid at design time ,every thing works fine but later I had to change it to dynamic bec I have to show multiple grids based upon the currencies in the database. I cannot hardcode the no. of grids as tommorow the no. of currencies(USD,EUR) may increase for the client...I hope u get my point...
0
 
RejojohnyConnect With a Mentor Commented:
I think I understand your design issue .. can I suggest couple of other options
group all the columns by "currency" and use heirarchical grid .. grid within a grid
OR
user a repeater control and add a grid within it which repeats for every currency ..

your problem might be that the dynamic grid is not been created in page load and so the events are not getting fired ..

Rejo
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.