?
Solved

Being stupid - ItemCommand trigger not firing

Posted on 2004-04-21
2
Medium Priority
?
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
zulu_11 earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month14 days, 20 hours left to enroll

771 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