Hi,
I am having data in Session and casting it to a Datatable.
and I want to delete some of the rows from that Datatable based on a comparison (please the code below).
it doesnt give the expected result.
could you please advise me on this??
Thanking you,
AGM Raja
I am having data in Session and casting it to a Datatable.
and I want to delete some of the rows from that Datatable based on a comparison (please the code below).
it doesnt give the expected result.
could you please advise me on this??
DataTable dtchange = (DataTable)Session["Data"];
DataSet ds = getdata(txt_HideDual.Text.ToString());
if (dtchange.Rows.Count != 0)
{
for (int i = 0; i < dtchange.Rows.Count; i++)
{
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
if (dtchange.Rows[i]["Name"].ToString() == ds.Tables[0].Rows[j]["Name"].ToString())
{
//dtchange.Rows.RemoveAt(i); --- This doesnt work
dtchange.Rows[i].Delete();
dtchange.AcceptChanges();
}
}
}
Session["Data"] = dtchange;
}
DataSet ds = getdata(txt_HideDual.Text.ToString());
if (dtchange.Rows.Count != 0)
{
for (int i = 0; i < dtchange.Rows.Count; i++)
{
for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
{
if (dtchange.Rows[i]["Name"].ToString() == ds.Tables[0].Rows[j]["Name"].ToString())
{
//dtchange.Rows.RemoveAt(i); --- This doesnt work
dtchange.Rows[i].Delete();
dtchange.AcceptChanges();
}
}
}
Session["Data"] = dtchange;
}
Thanking you,
AGM Raja