T
Tony
Hello!
Below is a method called GenerateGarmentDataSet which is passed a DataSet.
In this DataSet we have a DataTable with some columns and a couples of
DataRows.
Now to a strange thing. When I execute this statement(the row below) I have
to use ToString() before I can use Substring
newRow["BatchNo"] = (row["BatchRowId"]).ToString().Substring(4, 3);
but I have checked with this statement
Type type = row["BatchRowId"].GetType();
and the type is string so why do I need to use ToString when I already have
a string ?
private DataSet GenerateGarmentDataSet(DataSet ds)
{
DataSet nDs = new DataSet();
DataTable dt = CreateGarmentdDataTable();
foreach (DataRow row in ds.Tables[0].Rows)
{
DataRow newRow = dt.NewRow();
Type type = row["BatchRowId"].GetType();
newRow["BatchNo"] =
(row["BatchRowId"]).ToString().Substring(4, 3);
newRow["Trolley"] =
(row["BatchRowId"]).ToString().Substring(7,3);
newRow["Status"] = row["Status"];
newRow["OperationStep"] = row["Step"];
newRow["User"] = row["FirstName"].ToString() + " " +
row["LastName"].ToString();
newRow["StartTime"] = row["StartTime"];
dt.Rows.Add(newRow);
}
nDs.Tables.Add(dt);
return nDs;
}
//Tony
Below is a method called GenerateGarmentDataSet which is passed a DataSet.
In this DataSet we have a DataTable with some columns and a couples of
DataRows.
Now to a strange thing. When I execute this statement(the row below) I have
to use ToString() before I can use Substring
newRow["BatchNo"] = (row["BatchRowId"]).ToString().Substring(4, 3);
but I have checked with this statement
Type type = row["BatchRowId"].GetType();
and the type is string so why do I need to use ToString when I already have
a string ?
private DataSet GenerateGarmentDataSet(DataSet ds)
{
DataSet nDs = new DataSet();
DataTable dt = CreateGarmentdDataTable();
foreach (DataRow row in ds.Tables[0].Rows)
{
DataRow newRow = dt.NewRow();
Type type = row["BatchRowId"].GetType();
newRow["BatchNo"] =
(row["BatchRowId"]).ToString().Substring(4, 3);
newRow["Trolley"] =
(row["BatchRowId"]).ToString().Substring(7,3);
newRow["Status"] = row["Status"];
newRow["OperationStep"] = row["Step"];
newRow["User"] = row["FirstName"].ToString() + " " +
row["LastName"].ToString();
newRow["StartTime"] = row["StartTime"];
dt.Rows.Add(newRow);
}
nDs.Tables.Add(dt);
return nDs;
}
//Tony