GridView and the Factory Pattern.

S

sloan

I'm working on a application where I have

1 page which shows a GridView.

I have this page working...with sorting, with paging...and I'm caching the
first resultset,... to avoid unnecessary db calls after the first db hit.

...

The page needs to be called ... for 3 different reasons.
What I means is that.... for one flow, the page shows up...and has columns
like
EmpID,LastName,FirstName,SSN

Another UI flow...has the same grid, except I don't want the SSN, but do
want DOB (date of birth)
EmpID,LastName,FirstName,DOB

A third flow... and I want HomeTown
EmpID,LastName,FirstName,HomeTown

(this is a generic example, fyi).

I thought about...instead of hacking a bunch of code together...to create my
GridView via code..and get an instance via a factory.


public GridView GetAGridView(string key)
{
GridView gv = new GridView();
gv.//Add Colors and such....the thing which are in common to all
returned GridViews

gv.Columns.Add("EmpID");
gv.Columns.Add("LastName");
gv.Columns.Add("FirstName");

switch(key)
{
case "SSN":
gv.Columns.Add("SSN");//
break;
case "DOB":
gv.Columns.Add("DOB");
break;
case "HomeTown":
gv.Columns.Add("HomeTown");
break;
}

}


That code doesn't work..I'm just relaying the idea.



My questions are this:

A:
Can I programatically get access to each and every property of the GridView.
The Sorting, the Paging, the Header, the ItemTemplates.

A2. Anybody have a link to something like this..an example?

B:
I think I need to write up my handlers...in the codebehind of the aspx page.
Aka, it makes more sense to have the "_Sorting" handler coded in the code
behind page.

C:
Anyone see any flaws in this model, minus the lack of "WYSIWYG" development.
(Aka, its harder to code up a good looking GridView via code..then to set
properties and see the immediate results in the IDE.


...


Thanks,


Sloan
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top