Solved

Being stupid - ItemCommand trigger not firing

Posted on 2004-04-21
2
569 Views
Last Modified: 2012-08-14
When clicking on my commands in my datagrid, the ItemCommand is not getting fired

Item command in c#:
private void dgDocList_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs 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"></AlternatingItemStyle>
<ItemStyle CssClass="itemStyle"></ItemStyle>
<HeaderStyle CssClass="headerStyle"></HeaderStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="Document_ID">
<ItemStyle Width="1px"></ItemStyle>
</asp:BoundColumn>
<asp:ButtonColumn Text="Edit" CommandName="Edit" ItemStyle-Width="30px"></asp:ButtonColumn>
                        
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
0
Comment
Question by:bjohns33
2 Comments
 
LVL 6

Accepted Solution

by:
zulu_11 earned 500 total points
ID: 10877327
Most probably your ItemCommand Signature from the  IntializeComponent() is missing..this has happended to me a number of time using the VS.IDE...

just add the signature back in the IntializeComponent() as

this.dgDocList.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgDocList_ItemCommand);

I'm assuming that dgDocList is the id of the Datagrid that you are using...

Regards

Zulu
0
 
LVL 1

Author Comment

by:bjohns33
ID: 10878806
Thanks Zulu, that was it - it's always something simple isn't!
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question