473,657 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4831
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******** *****@TK2MSFTNG P02.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="IncPriceLab el" runat="server" Text = '<%#
(double)Eval("p rice") * 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
1373
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 Job.JobStatus field, which links to the JobStatus table, which holds this ID and a Description such as "Complete". In the DataGrid I want to go get this value and show that description rather than the ID field. What is the best way of doing...
0
983
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 the number of child ' products ds.Tables("Categories").Columns.Add("ProductsCount", GetType(Integer), _ "Count(Child(CatProducts).ProductID)")
1
1307
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 contains minutes. I want to create a calculated column that adds the minutes to the StartTime and is called EndTime. Any thought on how to go about doing this?
0
1077
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 doing right now: on page load i have: If Not Me.IsPostBack Then strSQL = "select FILEID, FILENAME, APPSERVICETYPE,LOCATION,FILEREPORT, DESCRIPTION, location2 FROM
0
1290
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 enough for my calculated columns. Can I use a custom function in calculated columns ?
1
3525
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 columns is altered, the calculated columns are only updated when I move to another row. If I move the focus to another cell within the same row, they are not refreshed. What is the best way to force this refresh? Greg
1
11228
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 (formerly ItemDataBound) than to mess with complicated templates, especially for things that are consistent across grids or columns. GridView is dumping all the nice stuff put there during a RowDataBound event. Ex: those "!" icons in outlook or...
1
1768
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 the char month of the date, and another column, the year on the date. Can anyone suggest a good way, and or point me in the right direction Thanks
9
4777
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 information populates the first two columns. I want the user to be able to enter data into the second two columns' rows. Is this possible and, if it is, how is it accomplished? Following is the code for the gridview: Private Sub BindGridView() ...
0
8384
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8820
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8499
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7314
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.