Here is one way you could do it in your custom Insert page:
protected void Page_PreRender(object sender, EventArgs e) {
var fieldTemplate = (FieldTemplateUserControl)DetailsView1.FindFieldTemplate("YourFieldName");
var tb = (TextBox)fieldTemplate.FindControl("TextBox1");
tb.Text = "Some text";
}
Note that this needs to go in your Page_PreRender and not Page_Load. We are looking at adding a new property to FieldTemplateUserControl that will avoid having to call FindControl, but for now this should work.
thanks,
David
Marked as answer by marcind on Apr 15, 2008 08:51 PM
JBravo69
0 Points
7 Posts
Access Dynamic Controls
Apr 15, 2008 11:53 AM|LINK
Hi Guys,
I have a list page with Jobs on it that has a link to Job Notes, We click through to Job Notes want to insert a new note against this Job.
On my custom insert page (page_load) I pull the current user from membership and get the correct ID for this user to log against the Job.
On the page there is a field for the current user that is displayed and I want to populate this with the current userID when the page loads.
How do I find the control UserID in the page to assign it the userID?
I’m sorry if this is trivial but I’m trying to get to grips with where in dynamic data you can access controls to assign values dynamically.
Do you do this in the partial class , at the page level or create a control?
Thanks
Bravo
davidebb
Contributor
7006 Points
1366 Posts
Microsoft
Re: Access Dynamic Controls
Apr 15, 2008 03:33 PM|LINK
Here is one way you could do it in your custom Insert page:
protected void Page_PreRender(object sender, EventArgs e) {
var fieldTemplate = (FieldTemplateUserControl)DetailsView1.FindFieldTemplate("YourFieldName");
var tb = (TextBox)fieldTemplate.FindControl("TextBox1");
tb.Text = "Some text";
}
Note that this needs to go in your Page_PreRender and not Page_Load. We are looking at adding a new property to FieldTemplateUserControl that will avoid having to call FindControl, but for now this should work.
thanks,
David
JBravo69
0 Points
7 Posts
Re: Access Dynamic Controls
Apr 15, 2008 03:51 PM|LINK
Thanks David top man.[:D]