asp GridView页面更改性能不佳

时间:2017-07-19 13:06:59

标签: c# gridview dataview

特别是来自sharepoint的我的Webpart从WS获取对象数组。

我的页面更改功能,其中dv是DataView:

protected void gvList_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
              gvList.PageIndex = e.NewPageIndex;
              gvList.DataSource = dv;
              gvList.DataBind();
        }

我的观点:

<asp:GridView ID="gvList" runat="server" AutoGenerateColumns="False" 
GridLines="None" AllowPaging="True" AllowSorting="True" 
OnPageIndexChanging="gvList_PageIndexChanging" 
OnSorting="gvListaTickets_Sorting" ShowHeaderWhenEmpty="true" PagerStyle-
CssClass="Pagination" EnableViewState="false">`

我如何填充DataView:

 XmlSerializer serializer = new XmlSerializer(listAll.GetType());
    System.IO.StringWriter sw = new System.IO.StringWriter();
    serializer.Serialize(sw, listAll);

    ds = new DataSet();
    System.IO.StringReader reader = new System.IO.StringReader(sw.ToString());
    ds.ReadXml(reader);

    if (ds != null && ds.Tables[0].Rows.Count != 0)
    {
       dv = new DataView(ds.Tables[0]);
       gvList.DataSource = dv;
       gvList.DataBind();
    }

0 个答案:

没有答案