Link to home
Start Free TrialLog in
Avatar of Mr_Shaw
Mr_Shaw

asked on

FormView update a Label in PagerTemplate

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?
Avatar of guru_sami
guru_sami
Flag of United States of America image

Try something like this:

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

ASKER

the code does not recognise that there is a label in FormView1
ASKER CERTIFIED SOLUTION
Avatar of guru_sami
guru_sami
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mr_Shaw

ASKER

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

ASKER

The answer is the code goes into the Label PreRender.

Thanks for the help
Avatar of Mr_Shaw

ASKER

thanks
DataBound should do ...
Although I think the PageCount will be available in Page_Load and PreRender (but if using AJAX might throw some exception)