Dynamic EditItemTemplate

sysdesigner

Newcomer
Joined
Feb 8, 2004
Messages
10
I am dynamically building EditItemTemplate columns for a datagrid. Whenever
the "edit" or "update" commands are issued the event code fires but there
isn't any textbox controls in the Item collection. The following code yields a
"null" reference on postback, when there should be a textbox called txtOne in
the collection.

textBoxOne = (TextBox)e.Item.FindControl("txtOne");

Any ideas?

TIA ,
Shawn

PS. The following article shows the method that I am using to create the
template columns.

http://www.dotnetbips.com/displayarticle.aspx?id=84
 
Your method for finding the control is fine but the problem is in the way that you're creating the controls;

You are probably adding an ItemTemplate but not an EditItemTemplate, so for each ItemTemplate you add you need to also add an EditItemTemplate, (In this case as a TextBox control).
 
Back
Top