Can anyone help me how to access for example value of first cell in 4th column?
a b c d
1 2 3 5
g n m l
for example, how to access to value d, if that would be datatable?
Thanks.
This question is related to
c#
asp.net
visual-studio-2008
datatable
foreach(DataRow row in dt.Rows)
{
string value = row[3].ToString();
}
data d is in row 0 and column 3 for value d :
DataTable table;
String d = (String)table.Rows[0][3];
string abc= dt.Rows[0]["column name"].ToString();
You can also try (first cell in 4th column):
dt.Rows[0][3]
public V[] getV(DataTable dtCloned)
{
V[] objV = new V[dtCloned.Rows.Count];
MyClasses mc = new MyClasses();
int i = 0;
int intError = 0;
foreach (DataRow dr in dtCloned.Rows)
{
try
{
V vs = new V();
vs.R = int.Parse(mc.ReplaceChar(dr["r"].ToString()).Trim());
vs.S = Int64.Parse(mc.ReplaceChar(dr["s"].ToString()).Trim());
objV[i] = vs;
i++;
}
catch (Exception ex)
{
//
DataRow row = dtError.NewRow();
row["r"] = dr["r"].ToString();
row["s"] = dr["s"].ToString();
dtError.Rows.Add(row);
intError++;
}
}
return vs;
}
Source: Stackoverflow.com