Solved

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

Posted on 2004-08-19
4
538 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on 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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

710 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