Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

Postback and databinding question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Froefel - 27 Aug 2007 14:01 GMT
Probably a beginner's question:

My page has AutoEventWireup=true.
I have a gridview that's bound to an ObjectDataSource that returns
projects as a DataView. One of the columns is an Imagebutton that,
when clicked, takes the user to the details page of the requested
project.

Everything is working OK, except that too many events are firing
needlessly.
Here's the order of events when I first load the page:
   1. Page_Init
   2. Page_Load
   3. Page_PreRender
   4. ObjectDataSource's SelectMethod is called and returns a
Dataview
   5. GridView1_RowDataBound.... (for each row in the gridview
control because some icons need to be drawn based on each row's
content)

And here's the order of events when I subsequently click the link in
one the rows:
   1. Page_Init
   2. ObjectDataSource's SelectMethod is called and returns a
Dataview
   3. GridView1_RowDataBound
   4. Page_Load
   5. Page_PreRender
   6. GridView1_RowCommand
   [followed by the events for the new page]

When first loading the page, things are OK. However, when clicking the
link, it appears that too much is happening; the gridview should't be
repopulated because I'm moving away to another page anyway.
In the RowCommand event I packed the requested action
("SelectProject") in the CommandType parameter  and the selected
projectID in the CommandArgument, so I don't need access to the
gridview data anymore in order to go to the requested page.

How should I handle this? Any suggestions are welcome.

-- Hans
Andrew Robinson - 30 Aug 2007 15:07 GMT
Hans,

Your eventing sounds like a pretty typical page cycle. These events are
needed and your page has to rebuild so that button once again exists to
"receive" the event and fire away. One other approach would be to eliminate
your postback all together. Try using a 'asp:hyperlink' with the
'navigateurl' property set to a different page or possibly a 'asp:button' or
'asp:imagebutton' with the 'postbackurl' properties but you will embed your
command names and arguments into the url at the time that you build your
original page.

Hope this gets you going in the right direction.

Signature

Andrew Robinson
http://blog.binaryocean.com/

> Probably a beginner's question:
>
[quoted text clipped - 38 lines]
>
> -- Hans

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.