Solved

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

Posted on 2008-10-20
12
190 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
Get Actionable Data from Your Monitoring Solution

Your communication platform is only as good as the relevance of the information you send. Ensure your alerts get to the right people every time with actionable responses. Create escalation rules that ensure everyone follows the process and nothing is left to chance.

 
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

Containers & Docker to Create a Powerful Team

Containers are an incredibly powerful technology that can provide you and/or your engineering team with huge productivity gains. Using containers, you can deploy, back up, replicate, and move apps and their dependencies quickly and easily.

Question has a verified solution.

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

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.…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

696 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