By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,961 Members | 1,332 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,961 IT Pros & Developers. It's quick & easy.

Inherited class

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
> 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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.