DataGrid: asp:EditCommandColumn buttons does not call the _edit su

G

Guest

Hi,

The asp:EditCommandColumn template does not fire the _edit sutboutine
when the edit command column buttons are clicked. I get a Page Cannot Be
Displayed page error instead.

My (ASP 1.1) datagrid is defined in the HTML and the HTML <columns> has
one defined template column and it is an asp:EditCommandColumn (with edit
buttons). The datagrid's other columns are added at runtime by using the
technique documented in the MSDN article:

http://msdn.microsoft.com/library/d...emplatesprogrammaticallyindatagridcontrol.asp

The HTML is shown below in (1), the column class is shown in (2) and the
_edit subroutine signature is shown in (3).

Thank you for your help,

Scott

(1):
<ASP:DATAGRID id="MyDataGrid" runat="server" AutoGenerateColumns="False"
AllowSorting="True" Font-Names="Verdana"
AlternatingItemStyle-BackColor="Gainsboro"
OnItemDataBound="MyDataGrid_ItemBound" ShowFooter="True"
OnSortCommand="MyDataGrid_SortCommand" OnEditCommand="MyDataGrid_Edit"
OnCancelCommand="MyDataGrid_Cancel"
onDeleteCommand="MyDataGrid_DeleteCommand"
OnUpdateCommand="MyDataGrid_Update" BorderWidth="1px"
Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd"
BorderColor="Black" CellPadding="3" Height="441px">
<HeaderStyle BackColor="#AAAADD" Wrap="False"></HeaderStyle>
<Columns> <asp:EditCommandColumn ButtonType="PushButton"
UpdateText="Ok" HeaderText="Edit Info" CancelText="Cancel"
EditText="Edit"> <HeaderStyle Wrap="False" HorizontalAlign="Center"
Width="50px"></HeaderStyle>
<ItemStyle Wrap="False" Width="50px"></ItemStyle>
</asp:EditCommandColumn>
</Columns>
</ASP:DATAGRID>

(2):
Public Class DynamicDataGridTemplate
Implements ITemplate
Dim templateType As ListItemType
Dim columnName As String
Dim ColumnNum As Integer

Sub New(ByVal type As ListItemType, ByVal ColName As String, ByVal ColNum
As Integer)
templateType = type
columnName = ColName
columnNum = ColNum
End Sub

Sub InstantiateIn(ByVal container As Control) _
Implements ITemplate.InstantiateIn

Dim lc As New Literal
Dim chkBox1 As New CheckBox
Dim chkBox2 As New CheckBox
Select Case templateType
Case ListItemType.Header
If ColumnNum = 0 Then
lc.Text = "<B>" & columnName & "</B><BR>"
container.Controls.Add(lc)
Else
lc.Text = "<B>" & columnName & "</B><BR>"
container.Controls.Add(lc)
If ColumnNum = 1 Then
chkBox1.Text = "Asc"
If columnName.StartsWith("Acad") Then
chkBox1.Checked = False
Else
chkBox1.Checked = True
End If

chkBox1.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox1)
If columnName.StartsWith("Acad") Then
chkBox2.Checked = True
Else
chkBox2.Checked = False
End If
chkBox2.Text = "Desc"
chkBox2.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox2)
Else
chkBox1.Text = "Asc"
chkBox1.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox1)
chkBox2.Text = "Desc"
chkBox2.ID = "chkBox" & ColumnNum
container.Controls.Add(chkBox2)
End If
End If


Case ListItemType.Item
lc.Text = "Item " & columnName
container.Controls.Add(lc)
Case ListItemType.EditItem
Dim tb As New TextBox
tb.Text = ""
container.Controls.Add(tb)
Case ListItemType.Footer
lc.Text = "<I>Footer</I>"
container.Controls.Add(lc)
End Select
End Sub
End Class

(3):
Sub MyDataGrid_Edit(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles MyDataGrid.EditCommand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top