bjohns33
asked on
Being stupid - ItemCommand trigger not firing
When clicking on my commands in my datagrid, the ItemCommand is not getting fired
Item command in c#:
private void dgDocList_ItemCommand(obje ct source, System.Web.UI.WebControls. DataGridCo mmandEvent Args e)
{
//Get the document id of the selected document and store in viewstate.
_docId = int.Parse(e.Item.Cells[0]. Text);
ViewState["docId"] = _docId;
switch(e.CommandName)
{
case "Copy":
break;
case "Delete":
DeleteDocument();
break;
case "Edit":
EditDocument();
break;
case "More":
break;
default:
// Do nothing.
break;
}
}
First part of ASP code:
<asp:DataGrid id="dgDocList" runat="server" Width="747px" AutoGenerateColumns="False ">
<AlternatingItemStyle CssClass="altItemStyle"></ Alternatin gItemStyle >
<ItemStyle CssClass="itemStyle"></Ite mStyle>
<HeaderStyle CssClass="headerStyle"></H eaderStyle >
<Columns>
<asp:BoundColumn Visible="False" DataField="Document_ID">
<ItemStyle Width="1px"></ItemStyle>
</asp:BoundColumn>
<asp:ButtonColumn Text="Edit" CommandName="Edit" ItemStyle-Width="30px"></a sp:ButtonC olumn>
Any ideas? I've set a break point on the ItemCommand function and it's never reached.
This has to be something obvious that I'm missing, I'm sure, as I have this functionality working in other projects, and to my eye they don't look any different.
TIA
Ben
Item command in c#:
private void dgDocList_ItemCommand(obje
{
//Get the document id of the selected document and store in viewstate.
_docId = int.Parse(e.Item.Cells[0].
ViewState["docId"] = _docId;
switch(e.CommandName)
{
case "Copy":
break;
case "Delete":
DeleteDocument();
break;
case "Edit":
EditDocument();
break;
case "More":
break;
default:
// Do nothing.
break;
}
}
First part of ASP code:
<asp:DataGrid id="dgDocList" runat="server" Width="747px" AutoGenerateColumns="False
<AlternatingItemStyle CssClass="altItemStyle"></
<ItemStyle CssClass="itemStyle"></Ite
<HeaderStyle CssClass="headerStyle"></H
<Columns>
<asp:BoundColumn Visible="False" DataField="Document_ID">
<ItemStyle Width="1px"></ItemStyle>
</asp:BoundColumn>
<asp:ButtonColumn Text="Edit" CommandName="Edit" ItemStyle-Width="30px"></a
Any ideas? I've set a break point on the ItemCommand function and it's never reached.
This has to be something obvious that I'm missing, I'm sure, as I have this functionality working in other projects, and to my eye they don't look any different.
TIA
Ben
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER