Hi, I'm trying to build an ASP.NET display page using
datagrid. This datagrid must contain: ButtonColumn &
EditCommandColumn. This is part of my code:
<asp:DataGrid id="ItemsGrid"
BorderColor="black"
BorderWidth="1"
CellPadding="3"
OnEditCommand="ItemsGrid_Edit"
OnCancelCommand="ItemsGrid_Cancel"
OnUpdateCommand="ItemsGrid_Update"
OnItemCommand="ItemsGrid_Command"
AutoGenerateColumns="false"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<Columns>
<asp:EditCommandColumn
EditText="Edit"
CancelText="Cancel"
UpdateText="Update"
HeaderText="Edit item">
<ItemStyle Wrap="False">
</ItemStyle>
<HeaderStyle Wrap="False">
</HeaderStyle>
</asp:EditCommandColumn>
<asp:ButtonColumn
HeaderText="Delete item"
ButtonType="LinkButton"
Text="Delete"
CommandName="Delete"/>
Note that I also have defined "ItemsGrid_Edit",
"ItemsGrid_Cancel", "ItemsGrid_Update" and
"ItemsGrid_Command" in my VB code.
It all works fine. However, I want to create the
ButtonColumn & EditCommandColumn dynamically (i.e.
during run-time). So I removes those 2 pieces of ASP
code (asp:ButtonColumn & asp:EditCommandColumn) from
the aspx, and in my VB code, I add this:
Dim btnColumn As New ButtonColumn
btnColumn.ButtonType = ButtonColumnType.LinkButton
btnColumn.HeaderText = "Delete item"
btnColumn.Text = "Delete"
btnColumn.CommandName = "Delete"
Dim editColumn As New EditCommandColumn
editColumn.HeaderText = "Edit Item"
editColumn.ButtonType = ButtonColumnType.LinkButton
editColumn.UpdateText = "Update"
editColumn.CancelText = "Cancel"
editColumn.EditText = "E"
editColumn.ItemStyle.Wrap = False
ItemsGrid.Columns.Add(btnColumn)
ItemsGrid.Columns.Add(editColumn)
At first, it displays the grid correctly, however,
when I click on "Delete" or the "Edit" link button, it
never raises the event OnDeleteCommand nor
OnEditCommand!
Has anybody experienced this kind of problem as well?
Thanks a lot!
Adrian
__________________________________
Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.
http://promotions.yahoo.com/new_mail
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/