How to add calculated columns to a GridView?

  • Thread starter Thread starter SammyBar
  • Start date Start date
S

SammyBar

Hi,

I'm trying to display a DataSet data by using a GridView control on Visual
Studio 2005 professional. I'm displaying the DataSet directly, without using
the DataSource object. I can display selected columns from my DataSet, but I
need to display a grid column wich is the result of manipulating some
DataSet columns.
Obviously I can make the DataSet's table to include the needed column
precalculated and filled. But it means to couple the dataset to the grid
needs and I'd prefer to mantain the DataSet independent of the presentation
layer.
How can I do that?

Any hint is welcomed
Thanks in advance
Sammy
 
Hi,

I'm trying to display a DataSet data by using a GridView control on Visual
Studio 2005 professional. I'm displaying the DataSet directly, without using
the DataSource object. I can display selected columns from my DataSet, but I
need to display a grid column wich is the result of manipulating some
DataSet columns.
Obviously I can make the DataSet's table to include the needed column
precalculated and filled. But it means to couple the dataset to the grid
needs and I'd prefer to mantain the DataSet independent of the presentation
layer.
How can I do that?

Any hint is welcomed
Thanks in advance
Sammy

With templated columns you can bind data using an expression that does
the computation. For example:

<asp:Label ID="IncPriceLabel" runat="server" Text = '<%#
(double)Eval("price") * 1.175 %>' />

HTH
 
Back
Top