I have a page containing a FormView, which gets its data from a SqlDataSource control and displays details of a job. Two of the fields are location and job title. I want to re-use this data to create a dynamic page title. I know I can do this by setting the Page.Title to what I want to, but do I have access to the data outside of the FormView to which the data source is bound? If so how? Or will I have to perform an additional SELECT statement to get this data again?
Hi
No need to perform additional Select statement. You can access the FormView data in DataBound event. Try the following code:
protected void FormView1_DataBound(object sender, EventArgs e) { Page.Title = ((Label)(FormView1.Row.FindControl("column1Label"))).Text; } Hope this helps.|||
Brilliant. I've got that working nicely now, and discovered more events to play with
Thank you.
No comments:
Post a Comment