473,386 Members | 1,969 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,386 software developers and data experts.

DataTable Expression Column

My DataGrid is bound to a DataSet, with following columns: Description, CashExp, CreditExp,Frequency

On run time, I am adding two new DataColumn “AnnualCash” and “AnnualCredit” and defining Expression property to give product of two columns, as follows

Dim dc As DataColumn
dc = New DataColumn("AnnualCash", GetType(System.Single))
dc.Expression = " CashExp * Frequency"
myDataSet.Tables("ClientExpenses").Columns.Add(dc)

dc = New DataColumn("AnnualCredit", GetType(System.Single))
dc.Expression = " CreditExp * Frequency"
myDataSet.Tables("ClientExpenses").Columns.Add(dc)

The only problem I am getting is when CashExp or CreditExp or Frequency is changed the value of derived column is not changed (calculated) until user changes the row either by tab or arrow keys.

How can I change this behaviour so that the derived columns gets calculated when user edit values in a cell.

I have scoured through stacks of websites, posted to stacks of discussion forum, but no one seems to have a slightest clue about it.

Does that mean I have to ask my user to make sure to change the row, in order to get correct results?
Jul 21 '05 #1
1 4516
Hi PankajBanga

Add this on the right place where it is needed to force that what you want.

BindingContext(mydataset.Tables("ClientExpenses")) .EndCurrentEdit()

I hope this helps?

Cor

My DataGrid is bound to a DataSet, with following columns: Description, CashExp, CreditExp,Frequency
On run time, I am adding two new DataColumn "AnnualCash" and "AnnualCredit" and defining Expression property to give product of two
columns, as follows
Dim dc As DataColumn
dc = New DataColumn("AnnualCash", GetType(System.Single))
dc.Expression = " CashExp * Frequency"
myDataSet.TablesColumns.Add(dc)

dc = New DataColumn("AnnualCredit", GetType(System.Single))
dc.Expression = " CreditExp * Frequency"
myDataSet.Tables("ClientExpenses").Columns.Add(dc)

The only problem I am getting is when CashExp or CreditExp or Frequency is changed the value of derived column is not changed (calculated) until user
changes the row either by tab or arrow keys.
How can I change this behaviour so that the derived columns gets calculated when user edit values in a cell.
I have scoured through stacks of websites, posted to stacks of discussion forum, but no one seems to have a slightest clue about it.
Does that mean I have to ask my user to make sure to change the row, in order to get correct results?

Jul 21 '05 #2

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

Similar topics

1
by: Coreymas | last post by:
Hello everyone Here is what I am trying to do I have a datatable with 7 columns (called Mon, Tue, Wed,...) representing the days of the week I want to create a calculated column called...
3
by: MrNobody | last post by:
I've read that the expression property for DataColumns is used to "Sets or retrieves the expresssion used to filter rows, calculate the values in a column, or create an aggregate column.". I...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
1
by: Geoff Jones | last post by:
Hi Is it possible to change the type of data a column holds in DataTable at runtime? For example, suppose that the table column originally holds Strings, can we, at runtime, change it to...
11
by: Bruce D | last post by:
I have a DataTable that I need to merge the 'lastname' and 'firstname' fields to be displayed in a datagrid. I know I can use the SQL statement to merge the fields into one, but I want to know if...
2
by: Steve Amey | last post by:
Hi all I am storing some information in a database, including the Expression's for columns in a DataTable. In this Expression, I want to display 2 fields, Address and Contact, but seperated by a...
10
by: D. Shane Fowlkes | last post by:
I have a function that is called in page_load and the purpose of this function is to look up basic data in a MSSQL table and return it in the form of a datatable. The page_load will read the data...
4
by: Dennis | last post by:
I am trying to set up an Expression column in a DataTable for display in a DataGrid that subtract the column ("BirthDay") from todays date. I can't seem to get it right...is this possible? --...
0
by: Anish G | last post by:
Hi, I have an issue with reading CSV files. I am to reading CSV file and putting it in a Datatable in C#. I am using a regular expression to read the values. Below is the code. Now, it reads...
5
by: =?Utf-8?B?S3VuYWwgUGF0ZWw=?= | last post by:
I have a DataTable with Column DataType as Double I just want to show data in C# datagrid with two decimal places which property do I set for DataColum of DataTable and How? Thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.