protected void SearchEvent(object sender, EventArgs e) { string SearchQuery = "SELECT * FROM View_BusinessLocationDetails WHERE View_BusinessLocationDetails.BusinessLocationName LIKE '" + TBSearch.Text.Trim() + "%'"; DataSet DSRecord = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, SearchQuery); if (DSRecord.Tables[0].Rows.Count > 0) { GVBusinessLocation.DataSource = DSRecord.Tables[0]; GVBusinessLocation.DataBind(); } else { GVBusinessLocation.EmptyDataText = "No Record Found !"; GVBusinessLocation.DataBind(); } foreach (GridViewRow Row in GVBusinessLocation.Rows) { Label lblStatus = (Label)Row.FindControl("lblStatus"); LinkButton LBEdit = (LinkButton)Row.FindControl("LBEdit"); LinkButton LBDelete = (LinkButton)Row.FindControl("LBDelete"); if (lblStatus.Text == "Active") { lblStatus.CssClass = "label label-success"; LBEdit.Enabled = true; LBDelete.Enabled = true; } else { lblStatus.CssClass = "label label-danger"; LBEdit.Enabled = false; LBDelete.Enabled = false; } } }
private void BindGVBusinessLocation() { string SelectQuery = "SELECT * FROM View_BusinessLocationDetails"; DataSet DSRecord = SqlHelper.ExecuteDataset(Connection.connect(), CommandType.Text, SelectQuery); if (DSRecord.Tables[0].Rows.Count > 0) { GVBusinessLocation.DataSource = DSRecord.Tables[0]; GVBusinessLocation.DataBind(); } else { GVBusinessLocation.EmptyDataText = "No Record Found !"; GVBusinessLocation.DataBind(); } foreach (GridViewRow Row in GVBusinessLocation.Rows) { Label lblStatus = (Label)Row.FindControl("lblStatus"); LinkButton LBEdit = (LinkButton)Row.FindControl("LBEdit"); LinkButton LBDelete = (LinkButton)Row.FindControl("LBDelete"); if (lblStatus.Text == "Active") { lblStatus.CssClass = "label label-success"; LBEdit.Enabled = true; LBDelete.Enabled = true; } else { lblStatus.CssClass = "label label-danger"; LBEdit.Enabled = false; LBDelete.Enabled = false; } } }
protected void GVBusinessLocation_PageIndexChanging(object sender, GridViewPageEventArgs e) { GVBusinessLocation.PageIndex = e.NewPageIndex; BindGVBusinessLocation(); GVBusinessLocation.DataBind(); }