?
Solved

Problem Initializing edit command in a datagrid

Posted on 2006-05-09
4
Medium Priority
?
289 Views
Last Modified: 2008-02-01
this is my datagrid edit command function

private void dgProjects_EditCommand(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
                        {
                              Label mylabel;
                              
                              mylabel = ((Label)e.Item.FindControl("ProjectID"));
                              
                              Response.Redirect("projects.aspx?Page=1&ProjectID=" + mylabel);
                        }


when I add this link to the InitializeComponent function

      private void InitializeComponent()
            {    
                  
                  this.dgProjects.EditCommand += new System.EventHandler(this.dgProjects_EditCommand); this line has the error
                  this.dgProjects.SelectedIndexChanged += new System.EventHandler(this.dgProjects_SelectedIndexChanged);
                  
                  

            }

I get
does not match delegate void(system.eventhandler)


any ideas

Thanks

Jcook32
0
Comment
Question by:jcook32
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:dstanley9
ID: 16639113
EditCommand is a DataGridItemEvent delegate, not a plain Event delegate.

 try

              this.dgProjects.EditCommand += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgProjects_EditCommand);

0
 

Author Comment

by:jcook32
ID: 16639172
did not work
get an error on this part of the line
this.dgProjects.EditCommand += new

error is:
Cannot implicitly convert type 'System.Web.UI.WebControl.datagriditemeventhandler to
system.web.ui.webcontrols.datagridcommandeventhandler
0
 
LVL 25

Accepted Solution

by:
dstanley9 earned 1000 total points
ID: 16640466
Sorry, I didn't read which event you were hooking up to.  You're using the wrong type of event handler.  The DataGridItemEventHandler is used for ItemCreated and ItemDataBound (I assume you copied the method from somewhere else).

You need to change the signiature of your event handler to:

private void dgProjects_EditCommand(object sender, System.Web.UI.WebControls.DataGridCommandEventArgs e)
                    {
                         Label mylabel;
                         
                         mylabel = ((Label)e.Item.FindControl("ProjectID"));
                         
                         Response.Redirect("projects.aspx?Page=1&ProjectID=" + mylabel);
                    }

and use

this.dgProjects.EditCommand  += new DataGridCommandEventHandler(this.dgProjects_EditCommand);



0
 

Author Comment

by:jcook32
ID: 16640488
That worked thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

839 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