Example #1
0
    protected void GvCourse_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;
        GvCourse.DataSource = dt;
        GvCourse.DataBind();
        AllPageCode();
    }
Example #2
0
 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["dtCourse"];
         DataView  view       = new DataView(dtCurrency, condition, "", DataViewRowState.CurrentRows);
         GvCourse.DataSource  = view.ToTable();
         Session["dtFilter"]  = view.ToTable();
         lblTotalRecords.Text = Resources.Attendance.Total_Records + " : " + view.ToTable().Rows.Count + "";
         GvCourse.DataBind();
         AllPageCode();
     }
 }
Example #3
0
    protected void GvCourse_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GvCourse.PageIndex = e.NewPageIndex;
        DataTable dt = (DataTable)Session["dtFilter"];

        GvCourse.DataSource = dt;
        GvCourse.DataBind();
        AllPageCode();
    }
        public void show()
        {
            SqlConnection con   = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString);
            string        query = "select Id, CourseCode, CourseName from tblCourse";

            con.Open();
            SqlCommand cmd = new SqlCommand(query, con);

            cmd.ExecuteNonQuery();
            DataTable      dt  = new DataTable();
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            sda.Fill(dt);
            GvCourse.DataSource = dt;
            GvCourse.DataBind();
            con.Close();
        }
Example #5
0
    private void FillGrid()
    {
        DataTable dtBrand = objDesg.GetCourseMaster(Session["CompId"].ToString().ToString());

        lblTotalRecords.Text = Resources.Attendance.Total_Records + ": " + dtBrand.Rows.Count + "";
        Session["dtCourse"]  = dtBrand;
        Session["dtFilter"]  = dtBrand;
        if (dtBrand != null && dtBrand.Rows.Count > 0)
        {
            GvCourse.DataSource = dtBrand;
            GvCourse.DataBind();
            AllPageCode();
        }
        else
        {
            GvCourse.DataSource = null;
            GvCourse.DataBind();
        }
    }
        /// <summary>
        /// use ExecuteNonQuery method for displaying the course table data in gridview
        /// </summary>
        public void show()
        {
            //creating the database connection
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString);
            //selection query string for course table
            string query = "select Id, CourseCode, CourseName from tblCourse";

            con.Open(); //opening the connectuon
            //Instantiate a new command with a query and connection
            SqlCommand cmd = new SqlCommand(query, con);

            //Call ExecuteNonQuery to send command
            cmd.ExecuteNonQuery();
            //creating the new datatable
            DataTable      dt  = new DataTable(); //creating new datatable
            SqlDataAdapter sda = new SqlDataAdapter(cmd);

            sda.Fill(dt); //filling the datatable
            GvCourse.DataSource = dt;
            GvCourse.DataBind();
            con.Close(); //closing the datbase connection
        }