Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I update cell value of a data table?

Tags:

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.

like image 775
bhaveshkac Avatar asked Feb 16 '12 10:02

bhaveshkac


2 Answers

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.

like image 115
Davide Piras Avatar answered Oct 15 '22 08:10

Davide Piras


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.

like image 38
Sponsor Avatar answered Oct 15 '22 07:10

Sponsor