Solved

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

Posted on 2004-08-19
4
521 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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