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
340
Adding values to addRow
posted

I have a webDataGrid with addRow enabled.  If the grid is not empty, I need to copy some values from the last row of the grid into addRow colums.  How do I access the values in the last row of the gridview?  I am trying to do so using RowAdding_EnteringEditMode(sender, eventArgs) in javascript, but I can't find the values.

  • 10240
    posted

    Hi Jesse,

    Are you tying to get the values of a selected row? If so, you can do something like this:

    function getRows() {

    var grid = $find("<%=webdatagrid1.clientid>");

    alert(grid.get_behaviors().get_selection().get_selectedRows().getItem(0).get_element().innerText);

    }

    You will need to ensure that you have the selection behavior enabled on the grid for this to work.

    If your intent is not to base this off a user action but do this entirely on the client, you will need to tell the code which row you want the values for, so you will need to add the row(s) to the selected rows collection first, so something like this:

    function SelectRow() {
                var grid = $find("WebDataGrid1"); // my DataGrid has an Id of WebDataGrid1
                var gridRow = grid.get_rows().get_row(0);
                grid.get_behaviors().get_selection().get_selectedRows().add(gridRow);
            }


                

    Let me know if you need any additional assistance regarding this.