protected void grdCountry_ItemCommand(object source, DataGridCommandEventArgs e) { try { string strCa = e.CommandArgument.ToString(); string strWhere = " 1=1 "; DataGridItem item = default(DataGridItem); if (e.CommandName == "Edit") { _insert = false; DataTable dt = CountryService.Country_GetById(strCa); txtId.Value = dt.Rows[0]["CouId"].ToString(); txtName.Text = dt.Rows[0]["NameCo"].ToString(); chkActive.Checked = dt.Rows[0]["Status"].ToString() == "1" || dt.Rows[0]["Status"].ToString() == "True"; pnUpdate.Visible = true; pnView.Visible = false; } if (e.CommandName == "Delete") { CountryService.Country_Delete(strCa); BindGrid(); } if (e.CommandName == "Status") { string strA = ""; string str = e.Item.Cells[2].Text; strA = str == "1" ? "0" : "1"; CountryService.Country_Update_Status(strCa, strA); BindGrid(); } if (e.CommandName == "ascCountry") { if (Common.StringClass.Check(txtFilterName.Text)) { strWhere += " and NameCo like N'%" + txtFilterName.Text + "%' "; } if (Common.StringClass.Check(ddlFilterActive.SelectedValue)) { strWhere += " and Status = '" + ddlFilterActive.SelectedValue + "' "; } grdCountry.DataSource = CountryService.Country_GetByTop("", strWhere, "NameCo"); grdCountry.DataBind(); if (grdCountry.PageCount <= 1) { grdCountry.PagerStyle.Visible = false; } } if (e.CommandName == "descCountry") { if (Common.StringClass.Check(txtFilterName.Text)) { strWhere += " and NameCo like N'%" + txtFilterName.Text + "%' "; } if (Common.StringClass.Check(ddlFilterActive.SelectedValue)) { strWhere += " and Status = '" + ddlFilterActive.SelectedValue + "' "; } grdCountry.DataSource = CountryService.Country_GetByTop("", strWhere, "NameCo desc"); grdCountry.DataBind(); if (grdCountry.PageCount <= 1) { grdCountry.PagerStyle.Visible = false; } } } catch (Exception ex) { WebMsgBox.Show(ex.Message); } }