protected void GvGroup_Sorting(object sender, GridViewSortEventArgs e) { DataTable dt = (DataTable)Session["dtFilter"]; string sortdir = "DESC"; if (ViewState["SortDir"] != null) { sortdir = ViewState["SortDir"].ToString(); if (sortdir == "ASC") { e.SortDirection = SortDirection.Descending; ViewState["SortDir"] = "DESC"; } else { e.SortDirection = SortDirection.Ascending; ViewState["SortDir"] = "ASC"; } } else { ViewState["SortDir"] = "DESC"; } dt = (new DataView(dt, "", e.SortExpression + " " + ViewState["SortDir"].ToString(), DataViewRowState.CurrentRows)).ToTable(); Session["dtFilter"] = dt; GvGroup.DataSource = dt; GvGroup.DataBind(); AllPageCode(); }
protected void btnbindrpt_Click(object sender, ImageClickEventArgs e) { if (ddlOption.SelectedIndex != 0) { string condition = string.Empty; if (ddlOption.SelectedIndex == 1) { condition = "convert(" + ddlFieldName.SelectedValue + ",System.String)='" + txtValue.Text + "'"; } else if (ddlOption.SelectedIndex == 2) { condition = "convert(" + ddlFieldName.SelectedValue + ",System.String) like '%" + txtValue.Text + "%'"; } else { condition = "convert(" + ddlFieldName.SelectedValue + ",System.String) Like '" + txtValue.Text + "%'"; } DataTable dtCurrency = (DataTable)Session["dtGroup"]; DataView view = new DataView(dtCurrency, condition, "", DataViewRowState.CurrentRows); GvGroup.DataSource = view.ToTable(); Session["dtFilter"] = view.ToTable(); lblTotalRecords.Text = Resources.Attendance.Total_Records + " : " + view.ToTable().Rows.Count + ""; GvGroup.DataBind(); AllPageCode(); } }
protected void GvGroup_PageIndexChanging(object sender, GridViewPageEventArgs e) { GvGroup.PageIndex = e.NewPageIndex; DataTable dt = (DataTable)Session["dtFilter"]; GvGroup.DataSource = dt; GvGroup.DataBind(); AllPageCode(); }
public void show() { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString); string query = "select Id, GroupName, Year from tblGroup"; con.Open(); SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); GvGroup.DataSource = dt; GvGroup.DataBind(); con.Close(); }
protected void GvGroup_OnSorting(object sender, GridViewSortEventArgs e) { SortExpression = e.SortExpression; HDFSort.Value = HDFSort.Value == "ASC" ? "DESC" : "ASC"; DataTable dt = new DataTable(); dt = (DataTable)Session["dtFilter"]; DataView dv = new DataView(dt); string Query = "" + SortExpression + " " + HDFSort.Value + ""; dv.Sort = Query; dt = dv.ToTable(); Session["dtFilter"] = dt; GvGroup.DataSource = dt; GvGroup.DataBind(); AllPageCode(); }
/// <summary> /// use ExecuteNonQuery method for displaying the group table data in gridview /// </summary> public void show() { // Creating instance of SqlConnection SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString); string query = "select Id, GroupName, Year from tblGroup"; con.Open(); //Instantiate a new command with a query and connection SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); //Call ExecuteNonQuery to send command DataTable dt = new DataTable(); //creating new datatable SqlDataAdapter sda = new SqlDataAdapter(cmd); sda.Fill(dt); //filling the datatable GvGroup.DataSource = dt; GvGroup.DataBind(); con.Close(); //closing the database connection }
public void FillGrid() { DataTable dt = ObjGroupMaster.GetGroupMasterTrueAllData(StrCompId); if (dt.Rows.Count > 0) { GvGroup.DataSource = dt; GvGroup.DataBind(); } else { GvGroup.DataSource = null; GvGroup.DataBind(); } Session["Category"] = dt; Session["dtFilter"] = dt; AllPageCode(); lblTotalRecords.Text = Resources.Attendance.Total_Records + " : " + dt.Rows.Count.ToString() + ""; }
protected void ddlType_SelectedIndexChanged(object sender, EventArgs e) { if (ddlType.SelectedValue == "") { gvSearch.DataBind(); GvGroup.DataBind(); fieldListSubject.Visible = false; fieldCourse.Visible = false; } else { GvGroup.DataSource = biz.GetSubjectGroup(ddlType.SelectedValue); GvGroup.DataBind(); gvSearch.DataSource = biz.GetSubjectGroupSearch(ddlType.SelectedValue, 1, 100).DataResponse; gvSearch.DataBind(); fieldListSubject.Visible = true; fieldCourse.Visible = true; } }
private void FillGrid() { DataTable dtBrand = objEmpGroup.GetEmployeeGroup_Master(Session["CompId"].ToString().ToString()); dtBrand = new DataView(dtBrand, "Brand_Id='" + Session["BrandId"].ToString() + "' and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable(); lblTotalRecords.Text = Resources.Attendance.Total_Records + ": " + dtBrand.Rows.Count + ""; Session["dtGroup"] = dtBrand; Session["dtFilter"] = dtBrand; if (dtBrand != null && dtBrand.Rows.Count > 0) { GvGroup.DataSource = dtBrand; GvGroup.DataBind(); AllPageCode(); } else { GvGroup.DataSource = null; GvGroup.DataBind(); } }
protected void btnbind_Click(object sender, ImageClickEventArgs e) { string condition = string.Empty; if (ddlOption.SelectedIndex != 0) { if (ddlFieldName.SelectedValue == "ParentGroupName" && txtValue.Text == "") { condition = ddlFieldName.SelectedValue + " " + "is null"; } else { if (ddlOption.SelectedIndex == 1) { condition = "convert(" + ddlFieldName.SelectedValue + ",System.String)='" + txtValue.Text + "'"; } else if (ddlOption.SelectedIndex == 2) { condition = "convert(" + ddlFieldName.SelectedValue + ",System.String) like '%" + txtValue.Text + "%'"; } else { condition = "convert(" + ddlFieldName.SelectedValue + ",System.String) Like '" + txtValue.Text + "%'"; } } TreeViewCategory.Visible = false; GvGroup.Visible = true; btnGridView.ToolTip = Resources.Attendance.Tree_View; //Show grid if tree view is current shown DataTable dtCust = (DataTable)Session["Category"]; DataView view = new DataView(dtCust, condition, "", DataViewRowState.CurrentRows); Session["dtFilter"] = view.ToTable(); lblTotalRecords.Text = Resources.Attendance.Total_Records + " : " + view.ToTable().Rows.Count.ToString() + ""; GvGroup.DataSource = view.ToTable(); GvGroup.DataBind(); AllPageCode(); } }