Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
342
Add New row by user but with values added to 2 cols
posted

Hi,

I have a WebDataGrid attached to a SQLDataSource. 

fields: (CompositeKey: ControlNum; ControlNumSub)

ControlNum (Hidden)

ControlNumSub(ReadOnly)

DueDate

RecievedDate

CompletedCode

I want the user to be able to add a new row on the gird by entering the DueDate, RecievedDate and CompletedCode.  Once the user has entered the data they hit the <Enter> key.  Before the row is commited I would like to enter the ControlNum and ControlNumSub values in the gird through Javascript.  The ControlNum comes from a label that is on the same page.  The ControlNumSub field needs to be calculated in that I will have to extract the previous row's ControlNumSub value and add 1 to it. (ex. Previous row ControlNumSub = 2; New Row value should = 3).

How would set the value of ControlNum and ControlNumSub before the user commits the row?

Been trying to figure this out for weeks!! :( please help!

Kavita Patel

Parents
  • 33839
    Verified Answer
    posted

    Hi,

    You can handle the row adding client event and set the values there.

    function rowAdding(grid, args) {
                var cellVals = args.get_cellValues();
                for (var x = 0; x < cellVals.length; ++x) {
                    if (cellVals[x].DataKeyField == "ControlNum")
                        args.get_cellValues()[x].Value = yourVal;
                }
            }

    Let us know if you need more help.

    regards,

    David Young

Reply Children