Solved

How do I keep my formview from incrementing paging on postback?

Posted on 2008-10-20
12
187 Views
Last Modified: 2013-11-07
I have a formview that updates a few database fields via stored procedure when the user clicks the "Update" Link Button. The page needs to be in edit mode by default and then only show certain results after the user clicks the update button. I have my results in the ItemTemplate (READONLY MODE) and my page to be updated (I actually only need my radio buttons to update fields in the db...think as if you were taking a quiz...selecting an radio button for the answer)

I DO NOT want the page to show any Pager items while in EDIT mode...only in READONLY MODE after the database has been updated. I want the user to be able to go to the next record only if the current record has been updated(an answer has been chosen)...

So, the results page needs to show the Paging Links...the problem is that in my FORMVIEW, since the Update causes a postback, it wants to increment my paging. I don't want it to increment unless:

1) the user has already clicked the update button
2)they are in readonly mode on the results page.

Does this make sense? I have tried everything. Please help.  I don't want to cross page post back because all the data (results and everything is available in my database field. I only want to do some calculations, update the row and then display the pager items FOR THE SAME RECORD on the readonly results itemtemplate.
Please HELP!!!
0
Comment
Question by:bolenka
  • 6
  • 6
12 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 22767674
To disable paging in the Edit mode:
If (Me.FormView1.DefaultMode <> FormViewMode.ReadOnly) Then
    Me.FormView1.AllowPaging = False
Else
    Me.FormView1.AllowPaging = True
End If
To change paging after update:
In the ItemUpdated event handler, add these lines:

Me.FormView1.DefaultMode = FormViewMode.ReadOnly
Me.FormView1.AllowPaging = True
If (Me.FormView1.PageIndex + 1) <= Me.FormView1.PageCount Then
    Me.FormView1.PageIndex = Me.FormView1.PageIndex + 1
Else
    Me.FormView1.PageIndex = 0
End If
0
 

Author Comment

by:bolenka
ID: 22771311
ok great, but where do I call this? In databound? or what eventhandler?
0
 

Author Comment

by:bolenka
ID: 22771326
Sorry, I see you meant itmeupdated...but does the first one go in pageload?or pageloadcomplete if working with Master pages?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 22

Expert Comment

by:prairiedog
ID: 22771355
You can put it in Page_Load.
0
 

Author Comment

by:bolenka
ID: 22771548
Thanks. but i am using a stored procedure to update the record...will that still work?
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22771602
It has nothing to do with how you handle your data.
0
 

Author Comment

by:bolenka
ID: 22771647
oh, ok, well, it is not working. When I click the update button...it goes to the next record. I don't want it to do that. I want it to show the readonly mode of the same page before i can move to the next record. Please help.:) thanks so much.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22771707
Sorry for the misunderstanding.
In that case, all you need is these two lines:
Me.FormView1.DefaultMode = FormViewMode.ReadOnly
Me.FormView1.AllowPaging = True  
 
0
 

Author Comment

by:bolenka
ID: 22771985
where does this code go? In the page load also...Just this code?
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 22772981
In the same place: ItemUpdated.
0
 

Author Closing Comment

by:bolenka
ID: 31508707
thank you for everything. I hope I get you to answer more of my questions in the future. you were very helpful. I had to add a few other things to make the cod ework the way I wanted...but you pointed me in the right direction. Thanks so much.
0
 
LVL 22

Expert Comment

by:prairiedog
ID: 22776260
Thank you for the points and grade. It's been fun.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

776 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