We help IT Professionals succeed at work.

FormView update a Label in PagerTemplate

Mr_Shaw
Mr_Shaw asked
on
453 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?
Comment
Watch Question

Top Expert 2013

Commented:
Try something like this:

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

Author

Commented:
the code does not recognise that there is a label in FormView1
Top Expert 2013
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Do I add this into the formview preRender of the label preRender. Or should it gointo the formview DataBound

Author

Commented:
The answer is the code goes into the Label PreRender.

Thanks for the help

Author

Commented:
thanks
Top Expert 2013

Commented:
DataBound should do ...
Although I think the PageCount will be available in Page_Load and PreRender (but if using AJAX might throw some exception)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.