コード例 #1
0
ファイル: StudentsList.aspx.cs プロジェクト: andreazoi/Tests
        private void PopulatePager(int recordCount, int currentPage)
        {
            double dblPageCount = (double)((decimal)recordCount / decimal.Parse(ddlPageSize.SelectedValue));
            int    pageCount    = (int)Math.Ceiling(dblPageCount);

            LabelpageCurrent.Text = Convert.ToString(currentPage).Trim();
            Labeltptalrows.Text   = Convert.ToString(recordCount).Trim();
            Pagetotal.Text        = Convert.ToString(pageCount).Trim();
            List <ListItem> pages = new List <ListItem>();

            if (pageCount > 0)
            {
                pages.Add(new ListItem("First", "1", currentPage > 1));
                for (int i = 1; i <= pageCount; i++)
                {
                    pages.Add(new ListItem(i.ToString(), i.ToString(), i != currentPage));
                }
                pages.Add(new ListItem("Last", pageCount.ToString(), currentPage < pageCount));
            }


            rptPager.DataSource = pages;
            rptPager.DataBind();
            UpdatePanelgridview.Update();
        }
コード例 #2
0
ファイル: StudentsList.aspx.cs プロジェクト: andreazoi/Tests
        protected void Page_Changed(object sender, EventArgs e)
        {
            //int Aid = Convert.ToInt32(Session["id"].ToString().Trim());

            int pagesize  = Convert.ToInt32(ddlPageSize.SelectedValue);
            int pageIndex = int.Parse((sender as LinkButton).CommandArgument);

            int totalRows = 0;

            GridViewStudents.DataSource =
                commancode.GetStudents(pageIndex, pagesize, "surname ",
                                       "ASC", "allrep", out totalRows);

            GridViewStudents.DataBind();

            DatabindRepeater(pageIndex, pagesize, totalRows);

            //this.GetStudentssPageWise(pageIndex);
            UpdatePanelgridview.Update();
        }
コード例 #3
0
ファイル: StudentsList.aspx.cs プロジェクト: andreazoi/Tests
        //code for GridViewStudents_RowCommand
        protected void GridViewStudents_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteRow")
            {
                int rowIndex  = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                int InvoiceId = Convert.ToInt32(e.CommandArgument);



                SqlParameter parameter = new SqlParameter();
                parameter.ParameterName = "@Action";
                parameter.Value         = "Delete";
                SqlParameter parameter1 = new SqlParameter();
                parameter1.ParameterName = "@id";
                parameter1.Value         = InvoiceId;
                commancode.GetData("Sp_GetStudents", parameter, parameter1);
                gridbind();
                UpdatePanelgridview.Update();
            }


            else if (e.CommandName == "edit")
            {
                int    rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
                string Id       = ((Label)GridViewStudents.Rows[rowIndex].FindControl("LabelstudentCode")).Text.ToString();
                // int Id = Convert.ToInt32(e.CommandArgument);

                string name             = ((Label)GridViewStudents.Rows[rowIndex].FindControl("Labelname")).Text.ToString();
                string surname          = ((Label)GridViewStudents.Rows[rowIndex].FindControl("Labelsurname")).Text.ToString();
                string email            = ((Label)GridViewStudents.Rows[rowIndex].FindControl("Labelemail")).Text.ToString();
                string phone_number     = ((Label)GridViewStudents.Rows[rowIndex].FindControl("Labelphone_number")).Text.ToString();
                string registrationYear = ((Label)GridViewStudents.Rows[rowIndex].FindControl("LabelregistrationYear")).Text.ToString();
                string specialty        = ((Label)GridViewStudents.Rows[rowIndex].FindControl("Labelspecialty")).Text.ToString();


                Response.Redirect("editStudent.aspx?Id=" + Id + "&name=" + name + "&surname=" + surname + "&email=" + email + "&phone_number=" + phone_number + "&registrationYear=" + registrationYear + "&specialty=" + specialty);
            }
        }
コード例 #4
0
ファイル: StudentsList.aspx.cs プロジェクト: andreazoi/Tests
        private void DatabindRepeater(int pageIndex, int pageSize, int totalRows)
        {
            double dblPageCount = (double)((decimal)totalRows / decimal.Parse(ddlPageSize.SelectedValue));
            int    pageCount    = (int)Math.Ceiling(dblPageCount);

            LabelpageCurrent.Text = Convert.ToString(pageIndex).Trim();
            Labeltptalrows.Text   = Convert.ToString(totalRows).Trim();
            Pagetotal.Text        = Convert.ToString(pageCount).Trim();
            List <ListItem> pages = new List <ListItem>();

            if (pageCount > 0)
            {
                pages.Add(new ListItem("First", "1", pageIndex > 1));
                for (int i = 1; i <= pageCount; i++)
                {
                    pages.Add(new ListItem(i.ToString(), i.ToString(), i != pageIndex));
                }
                pages.Add(new ListItem("Last", pageCount.ToString(), pageIndex < pageCount));
            }

            rptPager.DataSource = pages;
            rptPager.DataBind();
            UpdatePanelgridview.Update();
        }