Solved

FormView update a Label in PagerTemplate

Posted on 2009-07-06
7
425 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
[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
  • 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 

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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 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