c# - page load with child grids taking too much of time in loading the page -
i have 3 grids - category grid, items grid , sub items grid. have category grid (grdcategories) , each category there many items bind child grids (grditems). every item there many sub items display in sub child grid (grdsubitems). problem page takes of time in loading data. html code below:
it takes minutes load data:
aspx
<asp:gridview id="grdcategories" runat="server" autogeneratecolumns="false" datakeynames="category" cssclass="menu_items" onrowdatabound="grdcategories_rowdatabound"> <columns> <asp:templatefield> <itemtemplate> <asp:panel id="pnlmealoptionsheader" runat="server" width="100%"> <h1> <a id='<%# eval("categoryx")%>'> <asp:label id="lblcategory" runat="server" text='<%#eval("category") %>' visible="false"></asp:label> <asp:label id="lblcategoryx" runat="server" text='<%#eval("categoryx") %>'></asp:label> </a> </h1> </asp:panel> <asp:panel runat="server" id="pnlmealoptionsbody"> <asp:label id="lblcategoryxx" runat="server" cssclass="title_2" text='<%#eval("categoryxx") %>'></asp:label> <!--items in category --> <asp:gridview id="grditems" runat="server" autogeneratecolumns="false" cssclass="active-grid" datakeynames="item" onrowdatabound="grditems_rowdatabound" showheader="false" > <columns> <asp:templatefield> <itemtemplate> <asp:label id="lblitem" runat="server" text='<%#eval("item") %>' visible="false"></asp:label> <asp:label id="lblitemx" cssclass="title" runat="server" text='<%#eval("itemx") %>'></asp:label> <asp:label id="lblitemxx" cssclass="title" runat="server" text='<%#eval("itemxx") %>' style=" font-size:smaller; font-weight:normal"></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield> <itemtemplate> <asp:gridview id="grdsubitems" runat="server" autogeneratecolumns="false" cssclass="" datakeynames="subitem" showheader="false" onrowdatabound="grdsubitems_rowdatabound"> <headerstyle horizontalalign="left" /> <columns> <asp:templatefield> <itemtemplate> <asp:label id="lblitem" runat="server" text='<%#eval("item") %>' visible="false"></asp:label> <asp:label id="lblsubitem" runat="server" text='<%#eval("subitem") %>' visible="false"></asp:label> <asp:label id="lblnoofoptions" runat="server" text='<%#eval("numofoptions") %>' visible="false"></asp:label> <asp:label id="lblsubitemx" cssclass="qty" runat="server" text='<%#eval("subitemx") %>'></asp:label> </itemtemplate> </asp:templatefield> <asp:templatefield> <itemtemplate> <asp:label id="lblprice" runat="server" cssclass="price" text='<%#string.format("£{0}",eval("sellingcost")) %>'></asp:label> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> </itemtemplate> </asp:templatefield> </columns> </asp:gridview> <!--end items in category --> </asp:panel> </itemtemplate> </asp:templatefield> </columns> <emptydatatemplate> <table width="900px"> <tr> <td align="center"> <h1> no data available</h1> </td> </tr> </table> </emptydatatemplate> </asp:gridview> code behind
categories gridview bind
private void fillcategoriesgrid() { dataset ds = new dataset(); shopcategorymapbl bl = new shopcategorymapbl(sessioncontext.systemuser); bl.fetchforshop(ds, rowid); grdcategories.datasource = ds.tables[0].defaultview; grdcategories.databind(); } items gridview bind
protected void grdcategories_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { gridview chktopings = e.row.findcontrol("grditems") gridview; label lblcategory = e.row.findcontrol("lblcategory") label; fillitemsgrid(chktopings, webhelper.cast(lblcategory.text, 0)); } } protected void fillitemsgrid(gridview grditems, int category) { try { //int cleanorder = cargobag.getvalue("cleanorder", 0); dataset adataset = new dataset(); itembl bl = new itembl(sessioncontext.systemuser); bl.fetchforcategory(adataset, category, rowid); grditems.datasource = adataset.tables[0]; grditems.databind(); } catch (exception ex) { } } sub items gridview bind
protected void grditems_rowdatabound(object sender, gridviewroweventargs e) { if (e.row.rowtype == datacontrolrowtype.datarow) { gridview grdsubitems = e.row.findcontrol("grdsubitems") gridview; label lblitem = e.row.findcontrol("lblitem") label; fillsubitemsgrid(grdsubitems, webhelper.cast(lblitem.text, 0)); } } protected void fillsubitemsgrid(gridview grdsubitems, int item) { try { //int cleanorder = cargobag.getvalue("cleanorder", 0); dataset adataset = new dataset(); subitembl bl = new subitembl(sessioncontext.systemuser); bl.fetchforitem(adataset, item); grdsubitems.datasource = adataset.tables[0]; grdsubitems.databind(); } catch (exception ex) { } }
you need provide of code before can provide accurate answer.
for example:
where subitembl defined?
also try see line exact bottleneck.
is
bl.fetchforcategory(adataset, category, rowid); or
grdsubitems.databind(); if above line bottleneck, note gridview binding datasource large number of data indeedslow. how large data?
Comments
Post a Comment