Add events to html table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I was wondering is it possible to create my own html table that has two
features.
1. it is databound and 2. create my own events for it?

The datagrid is nice and I do use it but I need to be able to customize it
for other events to occur with it.

Thanks,

JJ
 
JJ said:
The datagrid is nice and I do use it but I need to be able to customize it
for other events to occur with it.

Sure, have you tried subclassing the DataGrid?
1. it is databound and 2. create my own events for it?

DataGrid comes databound already, which saves you a hairy furball of
coding. :-)

Adding events is as simple as adding new fields typed as the Event-
Handler, declaring the event publicly (or internally), and writing a
method to invoke the event if it has any EventHandlers attached to
it. See this MSDN Library article for more information on adding
events,

http://msdn.microsoft.com/library/library/en-us/cpguide/html/cpconraisingeventsfromcomponent.asp

Override the DataGrid's virtual (overridable) methods to fire your
additional events at the right times during the control's lifecycle. If
you override these methods then just remember to always call the
base class' implementation of that method (before or after your
override does it's stuff, depending on the timing that you're going
for.)


Derek Harmon
 
Probably "subclassing" DataGrid is what you are looking for.

Creating your own events -- you can do it. Note that client-side events
already have default handlers. You just need to override the methods.

btw, what exactly is that you are looking for / lacking. As far as I
know, DataGrid is very extensive and exhaustive.

--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------
 
Hi Gaurav,

Sorry for the delay in replying, past couple of days everytime I tired to
access the newsgroups I would get a service unavailable error which I think
had to do with passport.

Ok here's the issue I need to use the datagrid for reporting purposes. I
need to be able to put in a blank line and check records for certain
conditions. I can check records on certain conditions using OnItemdatabound
event but then need to add a blank row. Also I need a subtotal line and I
thought an custom generated event would work here. What do you think?

Thanks,
JJ
 
Adding something at the end or at the start is simple.

Override the PrepareControlHierarchy method.

Whatever you wish to add in the start, add before calling
base.PrepareControlHierarchy. All that you plan to add later, add it
later.

I would suggest reading the actual implementation, for example, in Mono
(incidently, by myself ;-) ) at:

DataGrid:
http://cvs.hispalinux.es/cgi-bin/cv...ontent-type=text/x-cvsweb-markup&cvsroot=mono
Method: PrepareControlHierarchy

BaseDataList:
http://cvs.hispalinux.es/cgi-bin/cv...ontent-type=text/x-cvsweb-markup&cvsroot=mono
Method: Render

Hope that gives a detailed insight.


--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------
 
Back
Top