473,396 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to add calculated columns to a GridView?

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
Jul 22 '08 #1
2 4807
Why don't you make a template column and fill it in the RowDataBound event?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"SammyBar" <sa******@gmail.comwrote in message
news:uE*************@TK2MSFTNGP02.phx.gbl...
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


Jul 23 '08 #2
On 22 Jul, 16:09, "SammyBar" <sammy...@gmail.comwrote:
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
Jul 25 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve | last post by:
Visual Studio 2003 .Net C# I have a DataGrid showing my Job table. Some of the fields in this table are ID's linking to other tables for the displayable value. i.e. I store the ID 1003 in the...
0
by: Rythm Music | last post by:
I have seen examples and samples such that you can show the Related Tables Data in the current Table. The syntax is something like: ' add a new calculated column to the Categories table, with...
1
by: Sean | last post by:
I have a table I am using to load a DataSet.DataTable to display data on a DataGrid. I have a Column called StartTime that is a DateTime and I have a column called Duration that is an Int32, that...
0
by: samir | last post by:
hi i have a datagrid where i display some columns. i want to have some columns from the db and 2 i calculate,i can display it but problem is how to sort the calculated columns. here is what i am...
0
by: ad | last post by:
I used the new TableAdapter feature of VS2005. I want to create a complex calculated column when I desgin a DataTable in a typed dataset. The defined function like convert, len, isnull... in not...
1
by: Greg | last post by:
I'm using a DataGridView object bound to an xml datasource. I have added 2 unbound columns which are populated based on the calculations of data from other columns. When the data in the other...
1
by: =?Utf-8?B?V2VzbGV5IERhdmlzLCBHZW5lcmFsIER5bmFtaWNz | last post by:
I'm moving from years with the datagrid to a new project, .net 2.0, using GridView controls. Per past practice, it is often a lot easier to inject controls (or special formatting) in RowDataBound...
1
by: Robert Bravery | last post by:
HI All, I am looking for a way to create some calculated columns in my typed dataset (VS 2005). This must be based on a datetime column in an SQL2005 table. The calculated column should return...
9
by: JohnShell | last post by:
Hi, I created an ASP.NET 4 columns gridview programmatically using VB.NET. The first two columns are bound to checkboxes and a database. When the user selects one or more checkboxes the database...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.