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
520
Client Side Set DateTime Cell
posted

I have an UltraWebGrid with one of the columns structured with DataType="System.DateTime" and Format="MM/dd/yyyy". I am attempting to insert a new row into this grid on the client side and have all of the other cells correctly working except this one. The code I am using for inserting a new row is as follows:

var gridID = '<%= grd1.ClientID %>';

var grid = igtbl_getGridById(gridID);

igtbl_addNew(gridID, 0);

//Get the newly inserted row

var rows = igtbl_getGridById(gridID).Rows;

var newRow = rows.rows[rows.length - 1]; 

 

To set a value for each cell in the grid I use the following line, obviously changing the cell index for each cell:

 newRow.cells[0].setValue(val);

When I try to insert a value into the DateTime row, the cell remains blank. I have tried the following and both don't work:

newRow.cells[2].setValue(Date.parse(new Date())); //Pass date object

newRow.cells[2].setValue(new Date());  //Pass seconds since epoch

 

What is the correct way to pass a value into DateTime cells?