Solved

FormView update a Label in PagerTemplate

Posted on 2009-07-06
7
419 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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