protected void BtnRemoveShared_Click(object sender, EventArgs e) { GridViewRow row = ((System.Web.UI.WebControls.Button)sender).Parent.Parent as GridViewRow; ((List <string>)ViewState["sharedListAdded"]).RemoveAt(row.RowIndex); GVShared.DataSource = ((List <string>)ViewState["sharedListAdded"]); GVShared.DataBind(); }
protected void BtnSharedAdd_Click(object sender, EventArgs e) { string addMe = DDLShared.SelectedItem.Text; if (((List <string>)ViewState["sharedListAdded"]).Count == 0) { ((List <string>)ViewState["sharedListAdded"]).Add(addMe); GVShared.DataSource = ((List <string>)ViewState["sharedListAdded"]); GVShared.DataBind(); LblSharedAlert.Visible = false; } else { for (int i = 0; i < ((List <string>)ViewState["sharedListAdded"]).Count; i++) { if (((List <string>)ViewState["sharedListAdded"])[i].ToString() == addMe) { if (ReportToSelect == "RTR") { Utility.DisplayAlertMessage(Message.DepartmentAlreadyInList); } else if (ReportToSelect == "ROR") { Utility.DisplayAlertMessage(Message.SupplierAlreadyInList); } break; } if (i == ((List <string>)ViewState["sharedListAdded"]).Count - 1) { ((List <string>)ViewState["sharedListAdded"]).Add(addMe); GVShared.DataSource = ((List <string>)ViewState["sharedListAdded"]); GVShared.DataBind(); LblSharedAlert.Visible = false; break; } } } }