//datarow and datatable
protected void grdOpenVacancy_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int id = (int)grdOpenVacancy.DataKeys[e.RowIndex].Value;
DataTable dtOpenVacancy = ViewState["vwOpenVacancy"] as DataTable;
DataRow dr= dtOpenVacancy.AsEnumerable().Where(a=>a.Field<int>("ID") == id).FirstOrDefault();
//GridViewRow grdrow = grdOpenVacancy.Rows[e.RowIndex];
bool i = Repository.DeleteOpenVacancy(id);
// ddlCadreType_SelectedIndexChanged(null, null);
if (ViewState["dt2"] != null)
{
DataTable dt3 = (DataTable)ViewState["dt2"];
DataRow workRow = dt3.NewRow();
// workRow["Institute"] = grdrow.Cells[0].Text;
workRow["Institute"] = dr["InstituteName"];
workRow["Discipline"] = dr["disciplineName"];
workRow["cadrename"] = dr["cadreName"];
workRow["cadreID"] = dr["cadreID"];
workRow["SS"] = dr["SanctionedStrength"];
workRow["IP"] = dr["inposition"];
workRow["Vacancy"] = dr["vacancy"];
dt3.Rows.Add(workRow);
ViewState["dt2"] = dt3;
// grid row and grid view
//GridViewRow grdrow = grdOpenVacancy.Rows[e.RowIndex];
// workRow["Institute"] = grdrow.Cells[0].Text;
but in this case, grid column should have item template field.
No comments:
Post a Comment