Мне нужно, чтобы в таблицах первой таблицы пользователь выбирал строки для добавления с флажками в каждой строке, затем нажимал кнопку добавления строк под первой таблицей. Однако я не хочу, чтобы строки, которые уже были добавлены, были удалены и добавлены снова. Я только хочу добавить строки, которые еще не были добавлены. Вот мой код
protected void GetSelectedRecords(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[10] { new DataColumn("Marca"), new DataColumn("Designacion"), new DataColumn("Tipo"),
new DataColumn("Referencia"), new DataColumn("Plazo"),new DataColumn("nombre_proveedor"),
new DataColumn("cantidad_requerida"),new DataColumn("cantidad_pedida"), new DataColumn("cantidad_entregada"),
new DataColumn("precio_unitario")});
foreach (GridViewRow row in gvPurchases.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
CheckBox chkRow = (row.Cells[2].FindControl("chkRow") as CheckBox);
if (chkRow.Checked)
{
string brand = (row.Cells[1].FindControl("lblMarca") as Label).Text;
string designation = (row.Cells[1].FindControl("lblDesignacion") as Label).Text;
string type = (row.Cells[1].FindControl("lblType") as Label).Text;
string reference = (row.Cells[1].FindControl("lblReference") as Label).Text;
string paymentDeadLine = (row.Cells[1].FindControl("lblPaymentDeadline") as Label).Text;
string supplier = drSupplier.SelectedItem.Text;
string requiredQuantity = (row.Cells[1].FindControl("lblrequiredQuantity") as Label).Text;
string requestedQuantity = (row.Cells[1].FindControl("lblRequestedQuantity") as Label).Text;
string deliveredQuantity = (row.Cells[1].FindControl("lblDeliveredQuantity") as Label).Text;
string unitPrice = (row.Cells[1].FindControl("lblUnitPrice") as Label).Text;
dt.Rows.Add(brand, designation, type, reference, paymentDeadLine, supplier, requestedQuantity, deliveredQuantity, deliveredQuantity, unitPrice);
}
}
}
gvPurchasesSelected.DataSource = dt;
gvPurchasesSelected.DataBind();
}