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 June 27th, 2005, 07:13 PM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default Problem with button in a datagrid

I have a datagrid that contains an asp button in a template column.
I set the CommandName property to be "Edit" and inside the OnItemCommand eventhandler I have this routine:

if(e.CommandName == "Edit"){
//do stuffs here
}

On every page load,I refresh the datasource of the datagrid and rebind it.That's were I got the problem....

It seems that if I refresh the databinding I dont have the event triggered,or something I dont know happened in between.Could anybody explain what was happenning in there and any workaround for that?

All I want is to have the event triggered or the routine in the handler executed at the same time having the datasource refreshed on every page_load(postback or not)

Aldwin Enriquez
President,Software Engineer - Narrasoft Philippines Inc.
__________________
\"Dont you ever give up!\"
 
Old June 27th, 2005, 09:18 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Why do you need to refresh the datasource on every page load?

I'm not sure how you can accomplish the desired events with a regular reload of data.

-Peter
 
Old June 29th, 2005, 07:54 AM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default

coz I want to make sure, I have the updated information on every page load.

Aldwin Enriquez
"Dont you ever give up!"
 
Old June 29th, 2005, 10:24 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Hmm... interesting problem. Normally you wouldn't want to do this, but I can see to some extent why.

Here's a possible solution...

Execute your grid query and databind in the handler for PreRender. This event happens after the other events and such. Don't bind in Page_Load. This way, when you post an item Edit event, it will get caught. Then you can just set the edit item index and do nothing else. The query and bind during prerender will happen every time, and now that you have editItemIndex set, it will bind with the edit row intact as desired. The one catch is that you can not have any other page events cause a postback while you are editing otherwise you'll loose your edits when the prerender bind happens.

-Peter
 
Old June 30th, 2005, 06:29 AM
Authorized User
 
Join Date: Jun 2005
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default

Thanks Peter
That solves my problem.........



Aldwin Enriquez
"Dont you ever give up!"





Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Button on a DataGrid Ric_H ADO.NET 1 March 23rd, 2006 06:33 PM
Select Button on a DataGrid Ric_H General .NET 0 March 22nd, 2006 04:16 PM
Select Button on a DataGrid Ric_H C# 0 March 22nd, 2006 04:14 PM
Button in Datagrid rodmcleay C# 1 September 25th, 2005 06:13 AM
button on a datagrid narbones ASP.NET 1.x and 2.0 Application Design 0 June 17th, 2003 07:02 AM





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