none
datatable compute method OR column expression based on rowstate RRS feed

  • Question

  • Hi All,

    I like to add a new column to existing table called RowState of type string.

    I am trying to find different method to achive this instead going through all rows in table and checking their rowstate proprty

    Based on row's rowstate property the new column value will be 'I','U','D','E'

    Can i use compute or Column.Expression to set this values based on Rowstate of a Row? If so could you provice me the ans for this please.

     

    Thanks

     

     

     

    Monday, November 8, 2010 12:22 PM

Answers

  • Hello,

    If you work without loop, can I ask how can you get each row's state property and then assign a value to the column based on the RowState?

    As I understand, we could specify the added column's value with expression based on other columns, for example,

    dc.Expression = "[otherColumn]*10"; OR dc.Expression = "[OtherColumn]+'Hello'";

    For more Expression Syntax of DataColumn.Expression property, please refer to:
    http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

    Best regards


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have any feedback, please tell us.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by liurong luo Monday, November 15, 2010 7:51 AM
    Friday, November 12, 2010 3:01 AM