c# - DNN 7 Nested Repeater with LINQ -


i have used answer in below link example. can't imports statement work in ascx file. there way display data in inner repeater don't have import namespace? error namespace in ascx file - "error cs0246: type or namespace name 'data' not found (are missing using directive or assembly reference?) ---> system.web.httpcompileexception: "

databind repeater using linq group by

ascx

<%@ control language="c#" autoeventwireup="true" codebehind="view.ascx.cs" inherits="christoc.modules.productfilter.view" %> <%@ import  namespace="system.data" %> <asp:repeater id="rptcategories" runat="server" onitemdatabound="rptcategories_itemdatabound"> <itemtemplate>     <div>         category: <b><%# container.dataitem%></b>         <asp:repeater id="rptoptions" runat="server">             <footertemplate>                 <%="</ul>" %>             </footertemplate>             <headertemplate>                 <%= "<ul>"%>             </headertemplate>             <itemtemplate>                 <li>                     <%# ((data.datarow)container.dataitem)[1] %>, <%#  ((data.datarow)container.dataitem)[0] %>                 </li>             </itemtemplate>         </asp:repeater>     </div>                 </itemtemplate> 

code behind

var cc = new categorymappingscontroller();             var listview = cc.listcategories(moduleid);             catoptdata = listview.converttodatatable(record => new object[] { listview });             rptcategories.datasource = (from x in catoptdata.asenumerable() select x["categoryname"]).distinct(); ;             rptcategories.databind(); 

bound function

protected void rptcategories_itemdatabound(object sender, repeateritemeventargs e)     {         if (e.item.itemtype == listitemtype.item | e.item.itemtype == listitemtype.alternatingitem)         {             repeater rptr = (repeater)e.item.findcontrol("rptoptions");             rptr.datasource = catoptdata.asenumerable();//.where(x => x["categoryname"].equals(e.item.dataitem));             rptr.databind();              repeater nestedrepeater = (repeater)e.item.findcontrol("nestedrepeater");             nestedrepeater.datasource = e.item.dataitem;             nestedrepeater.databind();         }     } 

you importing system.data using data.xxx in code. compiler cannot find data namespace without help. either drop .data form import or data. code. suggest latter.

<%@ import  namespace="system.data" %> 

or:

<%# ((datarow)container.dataitem)[1] %>, <%#  ((datarow)container.dataitem)[0] %> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -