Datagrid Columns

F

Francis Muraya

I would like to know how to:
1.Create a datagrid column that is not mapped to a table
column but whose value is dependent on other columns, say
a TotalValue col whiich is equal to Qty*Price.
2.Validate datagrid rows
3.Change some column values before they are updated, say
to append a ProductCode column with a prefix "NY".
 
W

William Ryan

The first one, what you can do is create an expression column in the
underlying datatable called in this instance TotalValue which is Qty*Price.
By doing this, if QTY or Price are changed, the Total will be reflected
immediately
http://www.ondotnet.com/pub/a/dotnet/2003/05/26/datacolumn_expressions.html

You can use any of the methods of the grid like CurrentCellChanged or
Navigate. However, if you use a Strongly typed Dataset, validation will
occur without intervention since it won't allow data that doesn't comply to
the rules in it.

YOu can loop through your datatable using foreach or whatever loop you want.
Test that a column meets a certain condition and change the value of the
table value Row/Column by appending whatever you want on it.

HTH,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top