Inheriting code behind class

A

ashtek

Hi,
I have two (almost similar) web pages Page1 & Page2.
Both of them have a datagrid and databinding is done during runtime by
executing different stored procedures for each page. Datagrid has
customized paging.

Also, Page1's datagrid has 10 columns while Page2's datagrid has only 7
columns.

So, in Page1, I check for the current page name & accordingly execute
the stored procedure (SP! or SP2) to bind data.

In Page2.cs, in the code behind I wrote

public class Page2 : Page1
{

}

In Page2.aspx I copied all the code from Page1.aspx and removed the 3
columns in the datagrid.(these 3 columns are not referred in Page1.cs
code behind, they are hyperlinks).

(Is there any way to inherit Page2.aspx from Page1.aspx?)

This is working fine except that when I open Pag2.aspx it says "File
could not be loaded into web form designer.An exception occurred while
creating the instance - Object reference not set to an instance of an
object" but then it opens the file.

I want to if this is a good way of doing it or is there's any other
better way?

Thanks,
Ashish.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top