TextBox in FormView Insert Template

D

Dave

How can I set the Value of a Textbox that resides in a FormView Insert
Template?

Thanks
 
K

Karthik D V

Hi Dave,
If you are bounding controls in FormView InsertItemTemplate, then
you need to manipulate the control content in PreRender method. You
cannot set the textbox value in Page_Load event.

1. Attach the PreRender event for FormView Control.
2. Find the control you are looking for.
3. If the control is present, set the value.


protected void FormView1_PreRender(object sender, EventArgs e)
{
Control ctrl =
this.FormView1.FindControl("CompanyNameInsertInsertItemTextBox");
TextBox txt = ctrl as TextBox;
if (txt != null)
{
txt.Text = "Hai"; //Set like this.
}
}

There may be better way(s) than this. I hope it may help you.

-- karthik D V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top