I have an ASP.Net datagrid with a template column. At design time I added an
asp:panel to a template column.
I have enabled the Edit,Update, Cancel commands. At runtime in the
Datagrid_ItemCr eated event. I check the ItemType for Edit Item Type, then I
get the reference to the Panel in the column and add some new
controls(textbo xes) to the panel. I set the ID for the new controls with a
unique ID. This works great the controls are created and displayed and I can
edit the data in the controls. However when I click the "Update Button" my
Panel is coming back empty. I have the Sub that handles the UpdateCommand.
It is being called and I can get a reference to the Panel but the Panel
seems to have lost all its controls. I am looking for some help resolving
this issue.
Sample of the Code:
Sub MyDataGrid_Item Created()
oPanelTitle = CType(e.Item.Fi ndControl("pnlN ewTitle"), Panel)
oTableTitle = New Table
For Each oLanguage In _LanguageList
'Create a new tablerow
oTRTitle = New TableRow
'Create a new tablecell
oTDTitle = New TableCell
oTDTitle.Text = oLanguage.Name
'Add the tablecell to the tablerow
oTRTitle.Contro ls.Add(oTDTitle )
oTDTitle = New TableCell
oTDTitle.Vertic alAlign = VerticalAlign.T op
oText = New TextBox
oText.ID = EDITTITLE & oLanguage.LCID
oText.Text = oArticle.Title
oTDTitle.Contro ls.Add(oText)
oTRTitle.Contro ls.Add(oTDTitle )
'Add the tablerow to the table
oTableTitle.Con trols.Add(oTRTi tle)
Next
'Add the table to the panel
oPanelTitle.Con trols.Add(oTabl eTitle)
End Sub
Sub MyDataGrid_Upda te()
Dim TitleTextBox As TextBox
TitleTextBox = E.Item.Cells.It em(5).FindContr ol(NEWTITLE &
oLanguage.LCID)
End Sub
Thanks Neal
asp:panel to a template column.
I have enabled the Edit,Update, Cancel commands. At runtime in the
Datagrid_ItemCr eated event. I check the ItemType for Edit Item Type, then I
get the reference to the Panel in the column and add some new
controls(textbo xes) to the panel. I set the ID for the new controls with a
unique ID. This works great the controls are created and displayed and I can
edit the data in the controls. However when I click the "Update Button" my
Panel is coming back empty. I have the Sub that handles the UpdateCommand.
It is being called and I can get a reference to the Panel but the Panel
seems to have lost all its controls. I am looking for some help resolving
this issue.
Sample of the Code:
Sub MyDataGrid_Item Created()
oPanelTitle = CType(e.Item.Fi ndControl("pnlN ewTitle"), Panel)
oTableTitle = New Table
For Each oLanguage In _LanguageList
'Create a new tablerow
oTRTitle = New TableRow
'Create a new tablecell
oTDTitle = New TableCell
oTDTitle.Text = oLanguage.Name
'Add the tablecell to the tablerow
oTRTitle.Contro ls.Add(oTDTitle )
oTDTitle = New TableCell
oTDTitle.Vertic alAlign = VerticalAlign.T op
oText = New TextBox
oText.ID = EDITTITLE & oLanguage.LCID
oText.Text = oArticle.Title
oTDTitle.Contro ls.Add(oText)
oTRTitle.Contro ls.Add(oTDTitle )
'Add the tablerow to the table
oTableTitle.Con trols.Add(oTRTi tle)
Next
'Add the table to the panel
oPanelTitle.Con trols.Add(oTabl eTitle)
End Sub
Sub MyDataGrid_Upda te()
Dim TitleTextBox As TextBox
TitleTextBox = E.Item.Cells.It em(5).FindContr ol(NEWTITLE &
oLanguage.LCID)
End Sub
Thanks Neal