This is a migrated thread and some comments may be shown as answers.

Lost GridTemplateColumn dynamically created on postback

0 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wagner
Top achievements
Rank 1
Wagner asked on 16 Mar 2011, 09:30 PM
Hello!

I have a grid with a GridTemplateColumn created dynamically on Page_Init.

Dim gtc As New GridTemplateColumn
 
With gtc
    .UniqueName = "gtcQuest"
    .HeaderTemplate = New clsGridViewTemplate(GridItemType.Header, "Quest", "Quest.", "")
    .FilterTemplate = New clsGridViewTemplate(GridItemType.EditItem, "", "", "")
    .ItemTemplate = New clsGridViewTemplate(GridItemType.Item, "pnlQuest", "", "")
    .HeaderStyle.Width = Unit.Pixel(60)
    .HeaderStyle.HorizontalAlign = HorizontalAlign.Center
End With
 
radGrid.MasterTableView.Columns.AddAt(0, gtc)

And in ItemCreated:

Dim btnQuest As New Button
 
btnQuest.ID = "btnQuest"
DirectCast(e.Item.FindControl("pnlQuest"), Panel).Controls.Add(btnQuest)

The column display correctly, but when I use the Pager to move around the other pages the Init is not fired, only the ItemCreated and a error is throw because the panel pnlQuest doesn´t exists.

How I put the column in the grid viewstate to don´t have to create everytime?

Thanks!

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Wagner
Top achievements
Rank 1
Share this question
or