How do I check the value of a new column added RRS feed

  • Question

  • I need to be able to check the value of a column that is added to the datagrid by using the following

    (rowTanks.RowState == DataRowState.Modified || Convert.ToString(rowTanks["RecalculateSII"]= true))


    I get an error on the 2nd part stating that the "|| cannot not be applied to operands of type "bool" and "string"



    Thursday, September 6, 2007 5:07 PM

All replies

  • This is a basic c# syntax issue...

    - You are trying to assign true to rowTanks["RecalculateSII"]
    - You are trying to Convert.ToString the result of the assignment just mentionned.

    You probably want something like:

    (rowTanks.RowState == DataRowState.Modified || Convert.ToBoolean(rowTanks["RecalculateSII"])

    Thursday, September 6, 2007 6:03 PM

    thanks for your help - but my example may not have been explanitory enough.


    the rowTanks["RecaluclatedSII"] (boolean) is a strong typed added column to an existing datagrid.


    if I toggle that field in the grid it doesn't change the rowstate to modified and I need to loop thru the dataset if the value has been modified.


    I believe the problem is that the rowstate and the added column are of different datatypes and that is why it is not working.  However, I don't know what I should convert the "Recalculated" new column to in order to check it in the foreach loop.


    basically if the datarowstate.Modified OR the RecalculateSII is true I want to step into the if





    Thursday, September 6, 2007 6:20 PM