Hi,
I have a dataset which is used to populate my datagrid something like this:
My question is, how do I add a caluclated display column to the datagrid?
It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate,
ScoreCardScore, DetailsScore from Audits where SupplierID = " &
ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView
Thanks very much for any advice!
Dan 8 19544
I have not tried this, and I'm going out soon so I don't have time but . . .
..
One suggestion that you might like to try is to Add a total column before
filling the dataset. For the table containing the values to be calculated,
add a row_changed delegate. and simply put that value in the datagrid cell
each time a change is made.
Regards - OHM
Dan Keeley wrote: Hi,
I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
Regards - OHM# OneHandedMan{at }BTInternet{dot }com
Another way of solving this problem (I'm not saying it's better :-), is to
use a custom column style in the datagrid:
Data binding and Web Services using Custom Collections http://www.microsoft.com/belux/nl/ms...cewrapper.mspx
The data binding capabilities in .NET are great, you can bind many controls
to almost any type of data, but in some scenarios data binding has its
limitations. For example data binding is not possible when using custom
collections, instead of DataSets, coming from a Web Service. This article
explains the problem and a possible, easy-to-use, solution: a class that
dynamically builds wrapper classes at run time, which exposes the field
member of the proxy classes as properties.
--
Greetz,
Jan
_______________ _______________ ____
Read my weblog: http://weblogs.asp.net/jan
"Dan Keeley" <ma********@hot mail.com> schreef in bericht
news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like
this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
Untested.......
dstest.Tables(0 ).Columns.Add(" total")
Dim i As Integer
For i = 0 To dstest.Tables(0 ).Rows.Count - 1
dstest.Tables(0 ).Rows(i).Item( "total") =
dstest.Tables(0 ).Rows(i).Item( "price") *
dstest.Tables(0 ).Rows(i).Item( "qty")
Next
Let me know if this helps.........
"Dan Keeley" <ma********@hot mail.com> wrote in message
news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like
this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
When you bind to the dataset it will be there.
"scorpion53 061" <sc************ *************** *@yahoo.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. .. Untested.......
dstest.Tables(0 ).Columns.Add(" total") Dim i As Integer For i = 0 To dstest.Tables(0 ).Rows.Count - 1 dstest.Tables(0 ).Rows(i).Item( "total") = dstest.Tables(0 ).Rows(i).Item( "price") * dstest.Tables(0 ).Rows(i).Item( "qty") Next
Let me know if this helps.........
"Dan Keeley" <ma********@hot mail.com> wrote in message news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the
datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
Dan
Have you tried something like:
Dim myTable As DataTable = myDataSet.Table s("Name")
Dim myColumn As New DataColumn("Cal culated",
GetType(Decimal ), "col1 * col2")
myColumn.AutoIn crement = False
myColumn.ReadOn ly = True
myTable.Columns .Add(myColumn)
Sample adapted from: http://msdn.microsoft.com/library/de...ctorTopic4.asp
See the topic for DataColumn.Expr ession on the expression syntax allowed.
Of course if you are pre-defining your DataSet with an xsd, you can use the
designer to add the calculated column.
Hope this helps
Jay
"Dan Keeley" <ma********@hot mail.com> wrote in message
news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like
this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
you were right Jay sorry.......
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Dan Have you tried something like:
Dim myTable As DataTable = myDataSet.Table s("Name") Dim myColumn As New DataColumn("Cal culated", GetType(Decimal ), "col1 * col2") myColumn.AutoIn crement = False myColumn.ReadOn ly = True myTable.Columns .Add(myColumn)
Sample adapted from: http://msdn.microsoft.com/library/de...ctorTopic4.asp See the topic for DataColumn.Expr ession on the expression syntax allowed.
Of course if you are pre-defining your DataSet with an xsd, you can use
the designer to add the calculated column.
Hope this helps Jay
"Dan Keeley" <ma********@hot mail.com> wrote in message news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the
datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
excellent thats perfect!
I managed to do exactly what i wanted with an expression field
Cheers!
Dan
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Dan Have you tried something like:
Dim myTable As DataTable = myDataSet.Table s("Name") Dim myColumn As New DataColumn("Cal culated", GetType(Decimal ), "col1 * col2") myColumn.AutoIn crement = False myColumn.ReadOn ly = True myTable.Columns .Add(myColumn)
Sample adapted from: http://msdn.microsoft.com/library/de...ctorTopic4.asp See the topic for DataColumn.Expr ession on the expression syntax allowed.
Of course if you are pre-defining your DataSet with an xsd, you can use
the designer to add the calculated column.
Hope this helps Jay
"Dan Keeley" <ma********@hot mail.com> wrote in message news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the
datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
scorpion53061,
Don't be sorry, as sometimes you need to use the loop you demonstrated!
For example the expression you are attempting to calculate is too complex
for the ADO.NET expression syntax. (interest & financial calculations or
other custom functions).
Or you want to have explicit control over when the column is recalculated,
not have it recalculate automatically.
Note I can see using either the loop or the DataTable.Colum nChanging event
to handle complex expressions. If I was displaying the values in a Windows
Grid, I would probably use the event as the grid would then be updated as I
changed items. In ASP.NET or non-visual windows grids I would probably use
the loop...
For explicit control over when the recalculation occurs, the loop makes more
sense to me.
Hope this helps
Jay
"scorpion53 061" <sc************ *************** *@yahoo.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. you were right Jay sorry.......
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. Dan Have you tried something like:
Dim myTable As DataTable = myDataSet.Table s("Name") Dim myColumn As New DataColumn("Cal culated", GetType(Decimal ), "col1 * col2") myColumn.AutoIn crement = False myColumn.ReadOn ly = True myTable.Columns .Add(myColumn)
Sample adapted from: http://msdn.microsoft.com/library/de...ctorTopic4.asp See the topic for DataColumn.Expr ession on the expression syntax
allowed. Of course if you are pre-defining your DataSet with an xsd, you can use
the designer to add the calculated column.
Hope this helps Jay
"Dan Keeley" <ma********@hot mail.com> wrote in message news:jb******** ********@newsfe p4-winn.server.ntl i.net... Hi,
I have a dataset which is used to populate my datagrid something like this: My question is, how do I add a caluclated display column to the datagrid? It will be based on ScoreCardScore. ..
Dim Cmd As OleDbCommand = New OleDbCommand("S elect AuditDate, ScoreCardScore, DetailsScore from Audits where SupplierID = " & ComboItem.Value .ToString, conn)
' create the data adapter object and pass in the sql command object
myDataAdapter = New System.Data.Ole Db.OleDbDataAda pter(Cmd)
' Tell the myDataadabter to fill the dataset
myDataAdapter.F ill(myDataSet, "Name")
dgAudits.DataSo urce = myDataSet.Table s("Name").Defau ltView Thanks very much for any advice!
Dan
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark Kola |
last post by:
I have ran into an interesting situation. I have a calculated field
based on a combobox column that somtimes is not requerying when I
change the combo box value.
Combobox
cboCustomer
2 Columne - Widths 1;0 - LimitToList = Yes
Calculated TextBox -
ControlSource =cboCustomer.Column(1)
|
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)")
|
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?
|
by: Manish |
last post by:
Hey Guys
I am using a datagrid to extract information out of SQL Server
datbase. The fields extracted are category,week,budget,Last
Year,Forecast and Projection. Also i add a calculated column Week% to
the datatable. Also i add calculated row - SPLH(Revenue/Hours) and
AWR(Payroll/Hours) for each week. My grid layout is as follows-
Catgory Week Budget LY Fcst Projection Week%
Revenue 1 2000 1500 2400 2000
Cost ...
|
by: Manish |
last post by:
Hello Everyone
I am having weird problem in my datagrid bounded to datatable. My
datatable is populated from SQLServer database. DataGrid has
Calculated column Week% and Calculated record, SPLH.
An example of datagrid is
Category Amount Week%
Revenue 200
Cost 60 30
Hours 100
| |
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 ?
|
by: markm75c |
last post by:
Does anyone know of a way to sort a column which isnt databound or an
actual field in the database, but is derived from a method?
IE. I have a grid showing stats for softball, with a calculated field
called AVG, I want to be able to sort based on AVG when they click on
AVG.
I can't seem to find a way to do this out there.
Thanks!
|
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
|
by: SammyBar |
last post by:
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...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |