Reputation: 497
How can I update cell value of data table
if ((sr_no == "") && (customer_name != ""))
{
string contact_no = SheetData.Tables[0].Rows[row].ItemArray[3].ToString();
Records.Rows[0].ItemArray[2]
}
I want to update cell of datatable if contact_no fround in next row.
Upvotes: 23
Views: 98514
Reputation: 161
for a specific column of all rows, (2 ==> column index (3rd column))
table.column(2).data().each( function ( value, index) {
table.cell(index, 2).data('update data');
}); table.draw();
Upvotes: 0
Reputation: 877
When using DataTables version 1.10.22, the previous answers did not work for me, but the following did work. If Records
is the DataTable, r
is the zero-based row index, and c
is the zero-based column index, then:
Record.cell( r, c ).data( value ).draw();
Calling draw()
at the end of the chain is optional, but forces the DataTable to update its internal caches.
Upvotes: 1
Reputation: 375
If you use Records.Rows[0].ItemArray[2] = value
this won't work, but if you use Records.Rows[0][2] = value
this works perfectly.
Upvotes: 13
Reputation: 44595
if Records
is your DataTable
do this:
Records.Rows[i][j] = value;
this does not answer the whole question but shows you how to set a value in a DataTable "cell".
you are using the ItemArray
which is not needed because once you have the right Row you can simply access its columns withh []
you can elaborate more and find out the final solution based on this hint.
Upvotes: 47