Solved

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

Posted on 2008-10-20
12
189 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

738 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