Home All Groups Group Topic Archive Search About

Handling events for Checkbox in Data Grid

Author
11 Mar 2005 7:59 PM
Abhijit Salvi via .NET 247
(Type your message here)

--------------------------------
From: Abhijit Salvi

Hi All,

    I am working on a DataGrid that has a column of Checkbox Controls. There is some Business Functionality that I need to accomplish when the Checkboxes in the column are checked or unchecked, basically on the 'onCheckChanged' Event of the checkbox.

    However I am not able to get handle to this event of the Checkbox.

    I have found numerous examples on the net for Checkbox in Repeaters but I guess the same does not work with checkbox in Data Grids. The 'onCheckChanged' event needs to be "raised".

    I get the following errors
'Public Event CheckedChanged(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.

'System.EventHandler' is a delegate type. Delegate construction permits only a single AddressOf expression as an argument list. Often an AddressOf expression can be used instead of a delegate construction.

    Have you or any body you know tried using Checkboxes in datagrid. I would greatly appreciate any help wrt this.

    Thanks in advance,

Regards,
Abhijit

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>o7c/dY/i9k++mHwoB+IKcQ==</Id>

Author
11 Mar 2005 9:22 PM
Elton Wang
Hi Abhijit,

In order to fire and handle the event of some server
control inside a datagrid, you can do following steps:

1. In its HTML code, set AutoPostBack=true and there is an
event trigger, e.g. OnCheckedChanged
="Event_handler_method_name".

2. There a Event_handler_method with two Args, Object and
EventArgs. In your case, it could be:

Public[/Protected] Sub CheckedChanged(sender As Object, e
As System.EventArgs)
   ' Code here
End Sub

3. Then coding in the method.

That's it!

HTH

Elton Wang
elton_w***@hotmail.com


>-----Original Message-----
>(Type your message here)
>
>--------------------------------
>From: Abhijit Salvi
>
>Hi All,
>
>    I am working on a DataGrid that has a column of
Checkbox Controls. There is some Business Functionality
that I need to accomplish when the Checkboxes in the
column are checked or unchecked, basically on
the 'onCheckChanged' Event of the checkbox.
>
>    However I am not able to get handle to this event of
the Checkbox.
>
>    I have found numerous examples on the net for
Checkbox in Repeaters but I guess the same does not work
with checkbox in Data Grids. The 'onCheckChanged' event
needs to be "raised".
>
>    I get the following errors
> 'Public Event CheckedChanged(sender As Object, e As
System.EventArgs)' is an event, and cannot be called
directly. Use a 'RaiseEvent' statement to raise an event.
>
>'System.EventHandler' is a delegate type. Delegate
construction permits only a single AddressOf expression as
an argument list. Often an AddressOf expression can be
used instead of a delegate construction.
>
>    Have you or any body you know tried using Checkboxes
in datagrid. I would greatly appreciate any help wrt this.
Show quoteHide quote
>
>    Thanks in advance,
>
>Regards,
>Abhijit
>
>-----------------------
>Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
><Id>o7c/dY/i9k++mHwoB+IKcQ==</Id>
>.
>