Solved

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

Posted on 2008-10-20
12
186 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Loop not working 29 47
C# Single Form 8 26
Advice on Xojo as a development tool over VB. 4 31
Write to file when application closes (by logoff) - VB.NET 1 13
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

10 Experts available now in Live!

Get 1:1 Help Now