PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Custom Columns in GridView

 
 
andytidy@gmail.com
Guest
Posts: n/a
 
      24th Jan 2008
After going through some newbie examples I've created a DAL and BLL
for my project. So far I simply display the DataTable to a GridView.
I can create custom columns that do simple functions, for example:

ReturnVal = UnitPrice - Discount

What I would like to do is have a little more flaxability without
creating stored procedures, such as:

if Customer.Sales > 100 then
ReturnVal = UnitPrice - Discount
else
ReturnVal = UnitPrice

I have tried, and failed, to base the GridView on the BLL rather than
the DataTable in the DAL. I don't quite think I've got on top of
Partial classes yet, when I try to add the new function I can't get it
displayed in the GridView.
 
Reply With Quote
 
 
 
 
Angel
Guest
Posts: n/a
 
      24th Jan 2008
Two things you need to realize about the GridView Control. First it was
designed to be used in a declarative environment which the old DataGrid did
not support. “Thank you God!” And because of it’s declarative nature it was
also meant to be used with the DataSource controls. What I hate about the
model is that it is too restrictive. I see tons of questions of people have
one issue or another with these controls that were suppose to be so easy to
use.

There is another property called DataSource that can be a life saver but I
will require you to write code. Remember normally you use DataSourceID to
which you wire a DataSource control. But DataSource will accept a dataset or
datatable which then makes things a little easier if you are building your
own middle tier. Write you methods so that they return a dataset or
datatable and hook it to the Gridview control with code

Dim b as new myBusiness.MyBll
GridView1.Datasource = b.GetData()
GridView1.DataBind()

That’s it! Of course almost immediately, you will realize that you need
more control over columns so it is possible to programmatically perform
column definitions that will allow you to customize validation, formatting
and event templates field all done programmatically.

The moral of the story is that if you want quick and dirty use the
declarative model but if you need control go to the old stand-by write code.
Use the empirical model.

Warning
With new power comes responsibility. The Declarative model freed you from
certain burdens associated with the Page Life Cycle. When you start coding
this is not the case now you have the responsibility of managing postbacks,
viewstate and other Data Binding issues. I guess the old say still applies
“Yous pays me now or Yous pays me later” :-)

--
aaa


"(E-Mail Removed)" wrote:

> After going through some newbie examples I've created a DAL and BLL
> for my project. So far I simply display the DataTable to a GridView.
> I can create custom columns that do simple functions, for example:
>
> ReturnVal = UnitPrice - Discount
>
> What I would like to do is have a little more flaxability without
> creating stored procedures, such as:
>
> if Customer.Sales > 100 then
> ReturnVal = UnitPrice - Discount
> else
> ReturnVal = UnitPrice
>
> I have tried, and failed, to base the GridView on the BLL rather than
> the DataTable in the DAL. I don't quite think I've got on top of
> Partial classes yet, when I try to add the new function I can't get it
> displayed in the GridView.
>

 
Reply With Quote
 
Angel
Guest
Posts: n/a
 
      24th Jan 2008
I have a piece of demo code that might give some ideas give me an email
address and I will be glad to send it to you
--
aaa


"(E-Mail Removed)" wrote:

> After going through some newbie examples I've created a DAL and BLL
> for my project. So far I simply display the DataTable to a GridView.
> I can create custom columns that do simple functions, for example:
>
> ReturnVal = UnitPrice - Discount
>
> What I would like to do is have a little more flaxability without
> creating stored procedures, such as:
>
> if Customer.Sales > 100 then
> ReturnVal = UnitPrice - Discount
> else
> ReturnVal = UnitPrice
>
> I have tried, and failed, to base the GridView on the BLL rather than
> the DataTable in the DAL. I don't quite think I've got on top of
> Partial classes yet, when I try to add the new function I can't get it
> displayed in the GridView.
>

 
Reply With Quote
 
andytidy@gmail.com
Guest
Posts: n/a
 
      30th Jan 2008
On Jan 25, 1:00*am, Angel <rodoo...@hotmail.com> wrote:
> I have a piece of demo code that might give some ideas give me an email
> address and I will be glad to send it to *you
> --
> aaa
>
>
>
> "andyt...@gmail.com" wrote:
> > After going through some newbie examples I've created a DAL and BLL
> > for my project. So far I simply display the DataTable to a GridView.
> > I can create custom columns that do simple functions, for example:

>
> > ReturnVal = UnitPrice - Discount

>
> > What I would like to do is have a little more flaxability without
> > creating stored procedures, such as:

>
> > if Customer.Sales > 100 then
> > * * ReturnVal = UnitPrice - Discount
> > else
> > * * ReturnVal = UnitPrice

>
> > I have tried, and failed, to base the GridView on the BLL rather than
> > the DataTable in the DAL. I don't quite think I've got on top of
> > Partial classes yet, when I try to add the new function I can't get it
> > displayed in the GridView.- Hide quoted text -

>
> - Show quoted text -


I guess what I'm looking for is a nice robust BLL. The MS examples go
a long way but I need to see what happens when I customize or extend
the DAL tables. It would seem that if I do extend the DAL tables in my
BLL I can't use the groovy wizards and tools for quick building of
controls.
The 3-tier method is better in this version, I just can't use all the
features of the new whiz bang controls.
So I will go the long way round and populate the lists, do the paging
and the details pages myself, the good ol' write code method.
Thanks for your help.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gridview columns Fritz the Cat Microsoft ASP .NET 3 30th Mar 2007 04:08 PM
Align table columns with gridview columns Jacksm Microsoft ASP .NET 2 21st Nov 2006 09:49 PM
Creating custom gridview (inheriting from gridview class) =?Utf-8?B?V2ViTWF0cml4?= Microsoft ASP .NET 1 22nd Oct 2006 12:56 AM
custom gridview columns Louis-Pierre Dauphinais Microsoft Dot NET 0 18th Sep 2006 06:13 PM
Aligning gridview columns with a custom header Carlos Microsoft ASP .NET 0 14th Aug 2006 08:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:52 AM.