Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2005, 03:14 PM
Authorized User
 
Join Date: Apr 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default Tricky DataGrid Events Issue

I have created a datagrid in a user control (.ascx) and i'm loading it into another page (.aspx). I create a Delete button column using the property editor and then use the properties tab in .NET to assign it an event on 'DeleteCommand'. .NET automatically inserts an event handler and method in the code, which i populate, but the event doesn't fire at run time. I do get a postback, but no event. I've read across the internet and this problem takes place in many different shapes and sizes. This one should be fairly simple, but I can't seem to fix it. I've even created a template control, added buttons, and assigned event handlers to those buttons at run time and still no go.

Any help would be great!

Actions are a direct result of your desires. Desire for good things.
__________________
Troubleshooting life: 1 bug at a time.
 
Old October 19th, 2005, 04:53 PM
Authorized User
 
Join Date: Apr 2005
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to DudeBori82 Send a message via MSN to DudeBori82
Default

And why the heck will it work if you use a link button? I just changed it from a normal click button to a link button (on the datagrid column) and it worked! I didn't really want links, so if any one can help me....

Actions are a direct result of your desires. Desire for good things.
 
Old October 21st, 2005, 04:13 PM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I ran into this.
I think it's a bug.

I solved it by running a Pre_Render event proc.
I don't know why this worked but it did.

Your problem *may* be that the page class can't see the vars of the ascx file.
Code:
private void Page_Load(object sender, System.EventArgs e)
{              
  this.PreRender += new EventHandler(ThePageClassName_PreRender);
  //. . . 
}
//. . . 
private void ThePageClassName_PreRender(object sender, EventArgs e)
{
    //Bind the DataGrid to it's source;     
}
 
Old October 21st, 2005, 04:26 PM
Authorized User
 
Join Date: Aug 2003
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've never tried to use the grid in an ascx.
I'm guessing you know that for the grid's events to fire you've gotta have something like (below) in the 'Web Form Designer generated code'

Because your grid is in an ascx you'll have to deal with the communication between the page and the ascx.
Code:
private void InitializeComponent()
{    
  this.DataGrid1.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemCreated);

  this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_ItemCommand);

       }





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Option's onclick,onchange events issue manishk73 Javascript 7 August 29th, 2008 01:20 PM
Events issue for programatically created GridView VadimZ ASP.NET 2.0 Professional 4 July 5th, 2007 05:11 PM
Datagrid Button Events Ric_H C# 0 April 5th, 2006 09:20 PM
Tricky Javascript/XSL issue...Hmmmm robster XSLT 1 January 23rd, 2004 11:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.