amchoni
amchoni

Reputation: 607

On postback lose value from dynamically created textbox gridview

I dynamically create gridview, and in this grid I have template field also

field.HeaderTemplate = New GridViewTemplate(ListItemType.Header, col.ColumnName)
field.ItemTemplate = New GridViewTemplate(ListItemType.Item, col.ColumnName)
grdEmpty.Columns.Add(bfield)

but when enter some value in text box in this template field i lose value on postback. And also on postback I lose all template field and i must re-create this grid.

My goal is: I have button and i want to add new row in this grid, but i want to have old value also.

I struggle with this all day, and any help is welcome.

Tnx,

Upvotes: 0

Views: 7706

Answers (1)

O.O
O.O

Reputation: 11317

Just recreate the grid during each postback. If you have viewstate enabled in the page and the gridview then the property will be restored.

See: here for more explanation

Upvotes: 1

Related Questions