Solved

FormView update a Label in PagerTemplate

Posted on 2009-07-06
7
422 Views
Last Modified: 2013-12-17
I would like to update the value of a Label in the FormView PagerTemplate.

I have tried doing the following but it does not wok.

FormView1.FindControl("Label_RecordTotal") = FormView1.PageCount.ToString();

Can anybody help?
0
Comment
Question by:Mr_Shaw
  • 4
  • 3
7 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24787223
Try something like this:

Label lbl= (Label) FormView1.FindControl("RLabel_RecordTotal");
if(lbl!=null)
{
lbl.Text =  FormView1.PageCount.ToString();
}
0
 

Author Comment

by:Mr_Shaw
ID: 24787385
the code does not recognise that there is a label in FormView1
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24787539
I think this should work...in your Pager.Position= Bottom

  Label lbl = (Label)FormView1.BottomPagerRow.FindControl("RLabel_RecordTotal");
        if (lbl != null)
        {
            lbl.Text = FormView1.PageCount.ToString();
        }
If it is Top / TopBottom it should vary accordingly.

Ref: http://forums.asp.net/p/908297/1010797.aspx
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:Mr_Shaw
ID: 24787679
Do I add this into the formview preRender of the label preRender. Or should it gointo the formview DataBound
0
 

Author Comment

by:Mr_Shaw
ID: 24787715
The answer is the code goes into the Label PreRender.

Thanks for the help
0
 

Author Closing Comment

by:Mr_Shaw
ID: 31600252
thanks
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24787748
DataBound should do ...
Although I think the PageCount will be available in Page_Load and PreRender (but if using AJAX might throw some exception)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 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