You should know which template your control should be in, that's why I added the if test in my code.
If you are currently in ReadOnly template then your control doesn't exist on the page, hence if you use FindControl("MyControl") it will return null.
One way to do it ignoring the current mode would be like this:
TextBox tb = (TextBox)FormView1.FindControl("TextBox1");
if (tb != null) {
//this means that the Control was found
tb.Text = Request.QueryString["text"];
}
In this approach you don't have to check the CurrentMode of the FormView. Maybe this is a better solution indeed.
Gabriel Bogéa (
http://www.gbogea.com)
-----------------
Please
'Mark as Answer' the post(s) that helped you