Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-08-19
4
Medium Priority
?
559 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 300 total points
ID: 11843249
do you create and/or add the grid programmatically?
0
 
LVL 4

Accepted Solution

by:
hamood earned 1200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

886 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