none
error on paging RRS feed

  • General discussion

  • using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using System.Collections.Generic;
    using System.Data;
    namespace OperationProjectList.ProjectList
    {
        public partial class ProjectListUserControl : UserControl
        {
            class Data
            {
                public string JobNO { get; set; }
                public string ProjectNo { get; set; }
                public string Delivery { get; set; }
            }
            protected void Page_Load(object sender, EventArgs e)
            {
                try
                {
                        DataTable data = Bindtogrid();
                        GridView1.DataSource = data;
                        GridView1.DataBind();
                    
                }
                catch (Exception ex)
                {
                }
            }
            public DataTable Bindtogrid()
            {
                DataSet T = new DataSet();
                Data d = new Data();
                SPList projectlist = SPContext.Current.Web.Lists["ProLis"];
                List<Data> data = new List<Data>();
                DataTable dt = new DataTable();
                DataRow dr;
                dt.Columns.Add("JobNo");
                dt.Columns.Add("ProjectNo");
                dt.Columns.Add("Delivery");
               
                foreach (SPListItem item in projectlist.Items)
                {
                        //d.JobNO = item["JobNo"].ToString();
                        //d.ProjectNo = item["ProjectNo"].ToString();
                        //d.Delivery = item["Delivery"].ToString();
                        //data.Add(d);
                        dr = dt.Rows.Add();
                        dr["JobNo"] = item["JobNo"] + "";
                        dr["ProjectNo"] = item["ProjectNo"] + "";
                        dr["Delivery"] = item["Delivery"] + "";
                    
                }
                return dt;
            }
            
          protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
            {
                GridView1.PageIndex = e.NewPageIndex;
                Bindtogrid();
            }
        }
    }

    Monday, November 5, 2012 11:27 AM