Solved

FormView update a Label in PagerTemplate

Posted on 2009-07-06
7
416 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
Comment Utility
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
Comment Utility
the code does not recognise that there is a label in FormView1
0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:Mr_Shaw
Comment Utility
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
Comment Utility
The answer is the code goes into the Label PreRender.

Thanks for the help
0
 

Author Closing Comment

by:Mr_Shaw
Comment Utility
thanks
0
 
LVL 41

Expert Comment

by:guru_sami
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

6 Experts available now in Live!

Get 1:1 Help Now