dynamically created event not firing 
Author Message
 dynamically created event not firing

Hi all,

I could really use some help with the following problem....

I have created a Datagrid programmatically, along with a ButtonColumn

      // create a new datagrid object named grdContactMethods
      grdContactMethods = new DataGrid();
      grdContactMethods.AutoGenerateColumns = false;
      grdContactMethods.ItemCommand += new
DataGridCommandEventHandler(grdContactMethods_Command);

      ButtonColumn tcolDelete = new ButtonColumn();
      tcolDelete.Text = "Del";
      grdContactMethods.Columns.Add(tcolDelete);

When I click on the button generated by the column defined above the
grdContactMethods_Command does not fire.

I tried changing....
  grdContactMethods.ItemCommand += new DataGrid ....
to...
  grdContactMethods.OnItemCommand += new DataGrid ....

But as soon as I change from ItemCommand to OnItemCommand I get the
following error:
"System.Web.UI.WebControls.DataGrid.OnItemCommand(System.Web.UI.WebControls.
DataGridCommandEventArgs)' is inaccessible due to its protection level"

If anybody can tell me how to fix this I would be eternally grateful.

Justin



Tue, 19 Apr 2005 13:23:22 GMT  
 dynamically created event not firing
Note that the OnItemCommand goes in to the Server Control, as follows,
you should check the example in MSDN help for DataGrid.ItemCommand:

From the MSDN Help files:

<asp:DataGrid id="ItemsGrid" runat="server"
                    BorderColor="black"
                    BorderWidth="1"
                    CellPadding="3"
                    AutoGenerateColumns="false"
                    OnItemCommand="Grid_CartCommand">

Chris R.


Quote:
> Hi all,

> I could really use some help with the following problem....

> I have created a Datagrid programmatically, along with a ButtonColumn

>       // create a new datagrid object named grdContactMethods
>       grdContactMethods = new DataGrid();
>       grdContactMethods.AutoGenerateColumns = false;
>       grdContactMethods.ItemCommand += new
> DataGridCommandEventHandler(grdContactMethods_Command);

>       ButtonColumn tcolDelete = new ButtonColumn();
>       tcolDelete.Text = "Del";
>       grdContactMethods.Columns.Add(tcolDelete);

> When I click on the button generated by the column defined above the
> grdContactMethods_Command does not fire.

> I tried changing....
>   grdContactMethods.ItemCommand += new DataGrid ....
> to...
>   grdContactMethods.OnItemCommand += new DataGrid ....

> But as soon as I change from ItemCommand to OnItemCommand I get the
> following error:

"System.Web.UI.WebControls.DataGrid.OnItemCommand(System.Web.UI.WebContr
ols.

- Show quoted text -

Quote:
> DataGridCommandEventArgs)' is inaccessible due to its protection
level"

> If anybody can tell me how to fix this I would be eternally grateful.

> Justin



Tue, 19 Apr 2005 21:12:49 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Dynamically creating buttons and firing events

2. How to handle an event fired from a control that was added dynamically

3. ImageButton Click Event Handler Not Getting Fired, why not

4. c# drop event not firing

5. SQLMERGXLib status event handler not firing

6. ControlBox click event not firing

7. MouseMove event not firing?

8. Events not firing?

9. ControlBox click event not firing

10. Creating threads and firing events in COM!

11. fire event in second thread does not work in MinDependency

12. ATL ActiveX Control Event not firing in IE?

 

 
Powered by phpBB® Forum Software