doramail05
asked on
asp.net add and delete row programmatically in gridview
i have collected supplier ids in a list called
List<long> lstSupplierIDs = Products.GetSupplierIDsByP roductID(l gProductId );
have a supplier gridview with supplier id as row id
trying to remove rows that contains supplier ids that in the lstSupplierIDs first
and then add the existing suppliers in the lstSupplierIDs on TOP rows of the gridview which order by 'datemodified' and have them checkbox checked.
not sure how to use datarow add with the specification above.
List<long> lstSupplierIDs = Products.GetSupplierIDsByP
have a supplier gridview with supplier id as row id
trying to remove rows that contains supplier ids that in the lstSupplierIDs first
and then add the existing suppliers in the lstSupplierIDs on TOP rows of the gridview which order by 'datemodified' and have them checkbox checked.
not sure how to use datarow add with the specification above.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
and the filldatarow :
private void FillDataRow(DataRow valRow, DataRow targetRow)
{
foreach (DataColumn col in valRow.Table.Columns)
{
if (targetRow.Table.Columns.Contains(col.ColumnName))
{
targetRow[col.ColumnName] = valRow[col];
}
}
}
ASKER
List<long> lstSupplierIDs = Products.GetSupplierIDsByP
DataTable dt3 = new DataTable();
DataTable dt4 = Products.GetSupplier_DT();
// DataTable dt4 = new DataTable();
foreach (long lgSuppID in lstSupplierIDs)
{
dt3 = Products.GetSupplierRowDT(
DataRow dr = dt3.Rows[0];
dt4.Rows.Remove(dr);
}
List<long> lstSupplierIDsDateModified
DataTable dt = new DataTable();
foreach (long lgSuppID in lstSupplierIDsDateModified
{
dt = Products.GetSupplierRowDT(
DataRow dr = dt.Rows[0];
dt4.Rows.Add(dr);
}
gvSupplier.DataSource = dt4;
gvSupplier.DataBind();
udpSupplier.Update();