I have a DataTable populated with samo data/values and I want to read data from DataTable and pass it to a string variable.
I have this code:
DataTable dr_art_line_2 = ds.Tables["QuantityInIssueUnit"];
I have a countert like this:
for (int i = 1; i <= broj_ds; i++ )
{
QuantityInIssueUnit_value => VALUE FROM DataTable
QuantityInIssueUnit_uom => VALUE FROM DataTable
}
Is this possible or not? If yes then how to pass data from DataTable to those variables?
Thanks!
DataTable dr_art_line_2 = ds.Tables["QuantityInIssueUnit"];
for (int i = 0; i < dr_art_line_2.Rows.Count; i++)
{
QuantityInIssueUnit_value = Convert.ToInt32(dr_art_line_2.Rows[i]["columnname"]);
//Similarly for QuantityInIssueUnit_uom.
}
You can do it using the foreach loop
DataTable dr_art_line_2 = ds.Tables["QuantityInIssueUnit"];
foreach(DataRow row in dr_art_line_2.Rows)
{
QuantityInIssueUnit_value = Convert.ToInt32(row["columnname"]);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With