Creating an EditCommandColumn from code

G

Guest

Hi

I have used the following code to essentially late bind an EditCommandColumn
to my datagrid in ASP.NET.

EditCommandColumn ec = new EditCommandColumn();
ec.ButtonType = ButtonColumnType.PushButton;
ec.CancelText = "Cancel";
ec.EditText = "Edit";
ec.HeaderText = "Rename";
ec.UpdateText = "Update";
ec.CausesValidation = true;
dtgResults.Columns.Add(ec);
ec = null;

However, the edit command that affects the grid in respect of changing
labels to textboxes does not fire even though I have set the datagrid to have
an OnUpdateCommand as follows

<asp:DataGrid id=dtgResults runat="server" AllowSorting="True"
OnDeleteCommand="DataDelete"
OnCancelCommand="DataCancel" OnEditCommand="DataEdit"
OnUpdateCommand="DataUpdate"
AllowPaging="True" PageSize="10" CellPadding="3"
BackColor="White"
BorderWidth="1px" AutoGenerateColumns="False"
AllowCustomPaging="false"
PagerStyle-Visible="false">

<FooterStyle CssClass="GridFooter" />
<SelectedItemStyle CssClass="GridItem" />
<ItemStyle CssClass="GridItem" />
<HeaderStyle CssClass="GridHeader" />
<AlternatingItemStyle CssClass="GridAlternateItem" />
</asp:DataGrid>

FYI, if i use the class method of creating the EditCommandColumn in the HTML
page, everything works fine

Any help would be appreciated
Ian
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top