Solved

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

Posted on 2008-10-20
12
185 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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now