473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Creating custom gridview (inheriting from gridview class)

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

Oct 21 '06 #1
1 11696
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
Oct 21 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my...
10
by: moondaddy | last post by:
I'm new to c# and .net 2.0. In the old vb.net 1.1 days I normally created a list class for every business class and used this list class for all databinding rather than using datasets. This is...
0
by: Nenefta | last post by:
Good afternoon everyone, I would like to create a custom GridViewand use that in the rest of my project, so all GridViews look the same. I thought it would be as easy as creating a usercontrol...
0
by: Louis-Pierre Dauphinais | last post by:
Please help, easily reproduced: 1. Create a class inheriting from System.Windows.Forms.DataGridViewTextBoxColumn . 2. Add a simple property to that class (see below for the code I used). 3. Add...
2
by: Greg | last post by:
Hello, I am trying to bind a GridView to a custom object I have created. First, here is what I'm trying to do: I have a wizard for adding/editing Users. When the wizard begins, a User...
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
5
by: Alias | last post by:
Hi - I'm trying to implement a custom RoleProvider based on the SqlRoleProvider. I keep receiving a an error that it can't load type 'MyRoleTest.MyRoleProvider' when trying to load my...
1
by: a | last post by:
Hi I would like to add some additional custom features to the listview, like cell editing. The created object will be added to the form as part of the GUI, and it should be able to handle...
1
by: Abdo Haji-Ali | last post by:
Previously I used to create user controls if I wanted to use a specific set of controls in multiple pages, however I want to deploy my control in other applications so I thought of creating custom...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.