Solved

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

Posted on 2004-08-19
4
499 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
Comment Utility
do you create and/or add the grid programmatically?
0
 
LVL 4

Accepted Solution

by:
hamood earned 400 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 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

16 Experts available now in Live!

Get 1:1 Help Now