Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Creating custom gridview (inheriting from gridview class)

Reply
Thread Tools

Creating custom gridview (inheriting from gridview class)

 
 
=?Utf-8?B?V2ViTWF0cml4?=
Guest
Posts: n/a
 
      10-21-2006
Hi,

I started a new web application which so far has several grdiviews
displaying data.
I find myself reimplementing the same logic (copy/pasting really) in grid's
event ItemDataBound and RowCreated and Sorting events to add certain effects.
For example inserting sorting direction image to the column header.
I want to create one custom grid view that implement all this logic to be
reused through out this app, so I wont need to copy paste code when adding a
new grid.
I know that I need to inherit from gridview class, in what method to I add
handlers for the events, do I need to override any methods? Any articles or
code samples ?

Thank you

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RGFsZQ==?=
Guest
Posts: n/a
 
      10-21-2006
There are actually a couple opprtunities for inheritance. Some of the
functionality you describe, for instance adding images for the sort column
headers, can be done several ways. You can create a user control wrapping
the GridView and add them in the OnInit method or Page_Load method.
Alternitavely, you can create a web custom control extending GridView and add
the functionality either in a public method or property or you can initialize
the common functionality in a method called by the constructor.

Other things you mention, such as adding event handlers, can't really be
handled in the extended control but, rather, should be handled in a
subclassed consumer of the control. For instance in your MasterPage or a
base page that extends System.Web.UI.Page. Your application pages then would
extend your custom base page rather than the default behavior of extending
System.Web.UI.Page directly.

HTH

Dale
--
Dale Preston
MCAD C#
MCSE, MCDBA


"WebMatrix" wrote:

> Hi,
>
> I started a new web application which so far has several grdiviews
> displaying data.
> I find myself reimplementing the same logic (copy/pasting really) in grid's
> event ItemDataBound and RowCreated and Sorting events to add certain effects.
> For example inserting sorting direction image to the column header.
> I want to create one custom grid view that implement all this logic to be
> reused through out this app, so I wont need to copy paste code when adding a
> new grid.
> I know that I need to inherit from gridview class, in what method to I add
> handlers for the events, do I need to override any methods? Any articles or
> code samples ?
>
> Thank you
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
creating custom GridView Nenefta ASP .Net 0 03-29-2006 12:03 PM
creating custom options for custom widgets? Alexandre Guimond Python 0 03-22-2006 05:55 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net Web Controls 0 06-01-2005 02:36 PM
"Error Creating Control" when creating a custom control (Design Time). Can't see tooltip message. Ravi Ambros Wallau ASP .Net 0 06-01-2005 02:36 PM



Advertisments