protected void gvCities_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) { try { if (e.CommandName == "TRUEorFALSE") { LinkButton lbtn = (LinkButton)e.CommandSource; string status = ""; if (lbtn.ToolTip == "TRUE") { status = "FALSE"; } else { status = "TRUE"; } objBal = new ClsBAL(); objBal.UpdateSourceStatus(status, e.CommandArgument.ToString()); DataSet ds = GetCitiesByLetter(ddlLetter.SelectedItem.Text.ToString()); gvCities.DataSource = ds; gvCities.DataBind(); } else if (e.CommandName == "OriginalIDtoID") { LinkButton lbtn = (LinkButton)e.CommandSource; //string status = ""; //if (lbtn.ToolTip == "TRUE") { status = "FALSE"; } else { status = "TRUE"; } objBal = new ClsBAL(); objBal.UpdateSource(lbtn.ToolTip.ToString(), e.CommandArgument.ToString(), e.CommandArgument.ToString()); DataSet ds = GetCitiesByLetter(ddlLetter.SelectedItem.Text.ToString()); gvCities.DataSource = ds; gvCities.DataBind(); } else if (e.CommandName == "SELECT") { LinkButton lbtn = (LinkButton)e.CommandSource; GridViewRow row = (GridViewRow)lbtn.NamingContainer; Label lblID = (Label)row.FindControl("lblID"); Label lblOriginalID = (Label)row.FindControl("lblOriginalID"); Label lblSourceName = (Label)row.FindControl("lblSourceName"); Label lblStatus = (Label)row.FindControl("lblStatus"); LinkButton lbtnMakeIt = (LinkButton)row.FindControl("lbtnMakeIt"); DataTable dtSources = null; if (HttpContext.Current.Session["Cities"] == null) { dtSources = new DataTable(); dtSources.Columns.Add("ID"); dtSources.Columns.Add("OriginalID"); dtSources.Columns.Add("SourceName"); dtSources.Columns.Add("Status"); DataRow dr = dtSources.NewRow(); dr["ID"] = lblID.Text.ToString(); dr["OriginalID"] = lblOriginalID.Text.ToString(); dr["SourceName"] = lblSourceName.Text.ToString(); dr["Status"] = lblStatus.Text.ToString(); dtSources.Rows.Add(dr); HttpContext.Current.Session["Cities"] = dtSources; } else { dtSources = (DataTable)HttpContext.Current.Session["Cities"]; DataRow dr = dtSources.NewRow(); dr["ID"] = lblID.Text.ToString(); dr["OriginalID"] = lblOriginalID.Text.ToString(); dr["SourceName"] = lblSourceName.Text.ToString(); dr["Status"] = lblStatus.Text.ToString(); dtSources.Rows.Add(dr); HttpContext.Current.Session["Cities"] = dtSources; } gv.Visible = true; gv.DataSource = dtSources; gv.DataBind(); if (gv.Rows.Count > 1) { btnSubmit.Visible = true; } else { btnSubmit.Visible = false; } } } catch (Exception) { throw; } }