none
Problem with setting the default value of a column while changing the value of another column RRS feed

  • Question

  • Hi:
    Hope this is not confusing for you guys.

    I have a table that has 2 columns, "SalesMan_ID" and "Commision"

    I have a data table defined called : m_dtLocationSalesReps

    I have an event handler m_dtLocationSalesReps_ColumnChanged that handles the m_dtLocationSalesReps.ColumnChanged event.

    so i want to set the value of Commission column, when a user chooses the sales man id

    Dim salesRep As etLocationSalesrep = CType(dr("Sales_Rep"), etLocationSalesrep)
           

    'this looks up the commision rate by sales_ID
    salesRep.CommissionPercentage = salesRep.CommissionPercentage = et.UI.CommonViews.DataSetHelper.GetCommisionBySalesID(CInt(dr("SalesMan_Employee_ID")))

    However, when I later set the default value,

    m_dtLocationSalesReps.Columns("Commission").DefaultValue = salesRep.CommissionPercentage

    a problem comes, the Commsision column in the current row is still defaults to zero.

    only the Commission column in the next row and the rows after that is set to the new value,  5% (the commssion rate)

    I think i am doing something wrong. i can't just set the Commission column on the current row i am working on, any ideas?

     

     

    Friday, April 15, 2011 10:15 PM

Answers

All replies

  • Hi Karen,

     What you mean is when you change the Columns("Commission").DefaultValue, the current row doesn't change but the value of next row changed, right? If so, that's said the code can work, but not in the right place. IMO, maybe there's something wrong with your logic of programme, so, if you have any time, could you please show us the whole code about this error? So that we can find the reason and correct it.

    Thanks,

    Tony

    Monday, April 18, 2011 6:22 AM
  •  

    Hi karen,

    Welcome!

    According to your description, I think you couldn't update the DefaultValue of the existing rows. DefaultValues are assigned when you add a row to the table and the column is not already assigned a value.( http://msdn.microsoft.com/en-us/library/system.data.datacolumn.defaultvalue.aspx). If you want to update the DefaultValue, you could copy the new row from current table to another table.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, April 20, 2011 3:42 AM
    Moderator
  • Hi karen,

    I am writing to check the status of the issue on your side.  Would you mind letting us know the result of the suggestions? 
     
    If you need further assistance, please feel free to let me know.   I will be more than happy to be of assistance.

     

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, April 29, 2011 3:59 AM
    Moderator