473,386 Members | 1,705 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,386 software developers and data experts.

Inherited class

Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA
Nov 19 '05 #1
8 1161
you can't just change the class from DataGrid to XXXDataGrid in the code
behind page. You have use the custom control in the aspx page as well other
wise it will think the type defined in the code behind page is DataGrid not
XXXDataGrid

HTH

Ollie Riches
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA

Nov 19 '05 #2
I understand what you say, but I want to use a normal DataGrid in ASPX
and extend the funcionnality in the code behind...

Perharps I need to do it another way...

Do you know how can I extend normal DataGrid's behaviour with a class ?

TIA

Ollie Riches wrote:
you can't just change the class from DataGrid to XXXDataGrid in the code
behind page. You have use the custom control in the aspx page as well other
wise it will think the type defined in the code behind page is DataGrid not
XXXDataGrid

HTH

Ollie Riches
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA


Nov 19 '05 #3
you can't just do it as class from the code behind you have to derive off
the control

Ollie Riches

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl...
I understand what you say, but I want to use a normal DataGrid in ASPX
and extend the funcionnality in the code behind...

Perharps I need to do it another way...

Do you know how can I extend normal DataGrid's behaviour with a class ?

TIA

Ollie Riches wrote:
you can't just change the class from DataGrid to XXXDataGrid in the code
behind page. You have use the custom control in the aspx page as well other wise it will think the type defined in the code behind page is DataGrid not XXXDataGrid

HTH

Ollie Riches
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA


Nov 19 '05 #4
> Do you know how can I extend normal DataGrid's behaviour with a class ?

Create a class. Inherit DataGrid. Extend it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl...
I understand what you say, but I want to use a normal DataGrid in ASPX and
extend the funcionnality in the code behind...

Perharps I need to do it another way...

Do you know how can I extend normal DataGrid's behaviour with a class ?

TIA

Ollie Riches wrote:
you can't just change the class from DataGrid to XXXDataGrid in the code
behind page. You have use the custom control in the aspx page as well
other
wise it will think the type defined in the code behind page is DataGrid
not
XXXDataGrid

HTH

Ollie Riches
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA



Nov 19 '05 #5
What everyone is telling you is that the control you place on your ASPX page
and the control defined in the code behind page are related. The relation
between the code behind page and the ASPX page is one of inheritance, the
latter being the more derived. I believe .NET will use reflection to link
the ASPX control with the code behind class at runtime.
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl...
I understand what you say, but I want to use a normal DataGrid in ASPX and
extend the funcionnality in the code behind...

Perharps I need to do it another way...

Do you know how can I extend normal DataGrid's behaviour with a class ?

TIA

Ollie Riches wrote:
you can't just change the class from DataGrid to XXXDataGrid in the code
behind page. You have use the custom control in the aspx page as well
other
wise it will think the type defined in the code behind page is DataGrid
not
XXXDataGrid

HTH

Ollie Riches
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...
Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA



Nov 19 '05 #6
Do you have some code/site to point me to ?

It's what I'm trying to do with no success...

TIA

Kevin Spencer wrote:
Do you know how can I extend normal DataGrid's behaviour with a class ?

Create a class. Inherit DataGrid. Extend it.

Nov 19 '05 #7
C# syntax:
public class foo
{
public int i;
}

public class bar : foo
{
public int x;
}

VB.Net syntax:
Public Class foo
Public Integer i
End Class

Public Class bar
Inherits foo
Public int x
End Class

In this example, the class foo has one field, and integer named "i". The
class bar inherits foo, so it also has a field named "i." In addition, it
defines a field named "x."

So, you can use all of the (public or protected) properties, fields, and
methods of the foo class in the bar class. You can also use the additional
properties of the bar class in the bar class, but not in the foo class.

Pretty straightforward, eh?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:eq**************@TK2MSFTNGP09.phx.gbl...
Do you have some code/site to point me to ?

It's what I'm trying to do with no success...

TIA

Kevin Spencer wrote:
Do you know how can I extend normal DataGrid's behaviour with a class ?

Create a class. Inherit DataGrid. Extend it.

Nov 19 '05 #8
Hold on a second Matt. The relationship between the CodeBehind CLASS and the
Page CLASS is one of inheritance. Note that this pertains ONLY to the Page
class. It has nothing to do with any Controls in it, other than the fact
that Controls you add to the Page Template is part of the Page Template's
extension of the CodeBehind's Page class. Also, a class is not "more
derived" from another class, any more than I am "more a son" to my mother.
No wonder Franck is confused!

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"MattC" <m@m.com> wrote in message
news:uA**************@TK2MSFTNGP11.phx.gbl...
What everyone is telling you is that the control you place on your ASPX
page and the control defined in the code behind page are related. The
relation between the code behind page and the ASPX page is one of
inheritance, the latter being the more derived. I believe .NET will use
reflection to link the ASPX control with the code behind class at runtime.
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:uP**************@TK2MSFTNGP10.phx.gbl...
I understand what you say, but I want to use a normal DataGrid in ASPX and
extend the funcionnality in the code behind...

Perharps I need to do it another way...

Do you know how can I extend normal DataGrid's behaviour with a class ?

TIA

Ollie Riches wrote:
you can't just change the class from DataGrid to XXXDataGrid in the code
behind page. You have use the custom control in the aspx page as well
other
wise it will think the type defined in the code behind page is DataGrid
not
XXXDataGrid

HTH

Ollie Riches
"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:OA**************@TK2MSFTNGP10.phx.gbl...

Hi, I'm using DataGrid a lot, and I would like to make a class with
DataGrid extended properties...

I make a class like this:
------------------------------------------------------
using System;
using System.Web.UI.WebControls;

namespace classes {

public class DataGridEx : DataGrid {

public DataGridEx() {}

}
}
------------------------------------------------------

And I in my aspx.cs I replace:

protected System.Web.UI.WebControls.DataGrid dgCustomers;
with:
protected classes.DataGridEx dgCustomers;

------------------------------------------------------

There is no error compiling, but I have this error when I browse the
aspx file:

The base class includes the field 'dgCustomers', but its type
(classes.DataGridEx) is not compatible with the type of control
(System.Web.UI.WebControls.DataGrid).

What am I missing ?

TIA

Nov 19 '05 #9

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

Similar topics

3
by: SLE | last post by:
Hi there, I know constructors are not inherited from the base class, not in VB.NET nor C# (nor Java I suppose). I never wondered,but reflecting on the reason why, I cannot find a solid answer. ...
8
by: TS | last post by:
I am trying to get set a property of a control on the inherited class from base class. I imagine i have to use reflection, so could someone give me the code to do it? something like this?...
4
by: Dan | last post by:
I have a need to make a set of classes that all share the same public methods, some implementation and some data. So, I made an abstract base (BaseClass) with an interface (IBaseClass) and a...
8
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
1
by: skootr | last post by:
I have a Public Interface defined in a class module. I also have a form that implements that interface After building the solution, I added an Inherited Form (inherited from the above-mentioned...
3
by: Jeff User | last post by:
Hello I am using C#, .net1.1 Vis Studio 2003 I am using homeBase.aspx.cs page as a base for several other aspx/aspx.cs web pages. The base page handles some operations that are common to all...
3
by: Wayne Brantley | last post by:
VS2005 RTM Create a web user control to use as a base class for other web user controls. Now, create a new web user control, change the class it inherits from to your base class and compile....
14
by: lovecreatesbea... | last post by:
Could you tell me how many class members the C++ language synthesizes for a class type? Which members in a class aren't derived from parent classes? I have read the book The C++ Programming...
12
by: Janaka Perera | last post by:
Hi All, We have done a object oriented design for a system which will create a class multiply inherited by around 1000 small and medium sized classes. I would be greatful if you can help me...
19
by: jan.loucka | last post by:
Hi, We're building a mapping application and inside we're using open source dll called MapServer. This dll uses object model that has quite a few classes. In our app we however need to little bit...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.