Note that there are some explanatory texts on larger screens.

plurals
  1. PODatagrid EditItemTemplate button event not firing
    primarykey
    data
    text
    <p>I am dynamically creating an Item template in a Gridview. </p> <pre><code>TemplateColumn BtnTmpField = new TemplateColumn(); BtnTmpField.ItemTemplate = new DynamicallyTemplatedGridViewHandler(ListItemType.Item, "Edit", "Button"); BtnTmpField.HeaderTemplate = new DynamicallyTemplatedGridViewHandler(ListItemType.Header, "Edit", "Command"); BtnTmpField.EditItemTemplate = new DynamicallyTemplatedGridViewHandler(ListItemType.EditItem, "Update", "Button"); dgdefault.Columns.Add(BtnTmpField); public void InstantiateIn(System.Web.UI.Control Container) { switch (ItemType) { case ListItemType.Header: Literal header_ltrl = new Literal(); header_ltrl.Text = "" + FieldName + ""; Container.Controls.Add(header_ltrl); break; case ListItemType.Item: switch (InfoType) { case "Button": LinkButton edit_button = new LinkButton(); edit_button.ID = "edit_button"; edit_button.Text = "Edit"; edit_button.CommandName = "Edit"; Container.Controls.Add(edit_button); break; } break; case ListItemType.EditItem: if (InfoType == "Button") { LinkButton update_button = new LinkButton(); update_button.ID = "update_button"; update_button.CommandName = "Update"; update_button.Text = "Update "; LinkButton cancel_button = new LinkButton(); cancel_button.ID = "cancel_button"; cancel_button.CommandName = "Cancel"; cancel_button.Text = "Cancel"; Container.Controls.Add(update_button); Container.Controls.Add(cancel_button); } break; } } </code></pre> <p>When I select the "Edit" button the "Update" and "Cancel" buttons show up with the selected row editable. The ItemCommand event of the DataGrid fires correctly when "Edit" is clicked. When I click the "Update" or "Cancel" buttons nothing fires. The ItemCommand doesn't fire, and neither does the UpdateCommand or CancelCommand when I explicitly put the onUpdateCommand or onCancelCommand in the ascx page. I can't figure out why nothing is firing when the buttons in the EditItemTemplate is clicked. Also Everything is being loaded on every page_init postback. Any tips would be helpful</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload