Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Postback and databinding question

Reply
Thread Tools

Postback and databinding question

 
 
Froefel
Guest
Posts: n/a
 
      08-27-2007
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

 
Reply With Quote
 
 
 
 
Andrew Robinson
Guest
Posts: n/a
 
      08-30-2007
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.

--

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


"Froefel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Repeater DataBinding on PostBack and base.DataBind() Oleg ASP .Net 1 09-25-2009 03:37 AM
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
repeater and databinding (postback) tarscher@gmail.com ASP .Net 1 10-11-2006 11:39 AM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM



Advertisments