Solved

asp:Datagrid in asp:table not triggerring ItemCommand() and PageIndexChanged() event?

Posted on 2004-08-19
4
511 Views
Last Modified: 2008-01-09
When I add an asp.net datagrid on a web form, the dg_ItemCommand() and dg_PAgeIndexChanged() events trigger ok when I click on the grid. When I add the datagrid to an asp.net table cell (using tablename.Rows(0).Cells(0).Controls.Add(dg), the datagrid displays ok, but the events are no longer triggerred.

I guess this is something to do with the events beings nested within the 'parent' table control. Is there any simple way to access the events again. I am programming in vb.net.

0
Comment
Question by:AlanPalan
  • 2
4 Comments
 
LVL 20

Assisted Solution

by:ihenry
ihenry earned 100 total points
ID: 11843249
do you create and/or add the grid programmatically?
0
 
LVL 4

Accepted Solution

by:
hamood earned 400 total points
ID: 11844355
I think you are not setting grid propoerties while adding it programatically. It would be more clear If you paste some code here.

Usually when we add control programatically then we set  its properties and attributes through code.

here is sample code for grid declaration

<asp:datagrid id="GridCategory" runat="server" Width="579px" OnItemCommand="GridCategory_ItemCommand            AutoGenerateColumns="False">

look at the event OnItemCommand declaration.

now you have to set attribute for this grid if you are doing it programatically like

gd.attributes.add("OnItemCommand", "GridCategory_ItemCommand")

hope this solves your problem

hamood
0
 

Author Comment

by:AlanPalan
ID: 11852865
I'm a bit confused. Thanks for your comments.

I've managed to solve this one by adding the datagrid to the asp:table at design time using the visual studio html editor. I make the datagrid invisible until I need it. The datagrid events then fire ok.

I think the problem arose somehow from adding the datagrid using table.rows(0).cells(0).controls.add(dg) at run time.

Not sure if this was what you were getting at hamood thanks for your thoughts anyway?

also jhenry, sounds like you might have been on to it?

0
 

Author Comment

by:AlanPalan
ID: 11852968
hamood, altough I solved it by adding controls in html designer rather than programatically, I think your solution would also be ok for future
jhenry sounds like you were on it too.
will do a points split
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now