?
Solved

FormView update a Label in PagerTemplate

Posted on 2009-07-06
7
Medium Priority
?
426 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

771 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