asp:ListView

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
4/1/2011 9:24:58 AM
Gravatar
Total Posts 76

asp:ListView

I am trying to create an add-on that allows the creation of reports (from our ERP system).  There are some things I don't understand and working on, such as only allowing access to specific reports based on roles (I will look in the documentation more about this).  This post is to get information on how to display the reports.  I would like to display them like this, unless someone else has a better idea on how to display them.  There are two tables, groups and reports.

* Group 1
      * Report 1
      * Report 2
      * Report 3

* Group 2
      * Report 1
      * Report 2
      * Report 3

I am using a ListView.  The problem comes in when I try to use another ListView inside.  Right now I am using SqlDataSource for testing purposes, but can't figure out how to access the control outside the inner listView if that makes any sense.  Here is the code.

<asp:ListView ID="ListView1" runat="server" DataKeyNames="GroupID" DataSourceID="SDS1">
                    <EmptyDataTemplate>
                        No data was returned.
                    </EmptyDataTemplate>
                    <ItemSeparatorTemplate>
                        <br />
                    </ItemSeparatorTemplate>
                    <ItemTemplate>
                        <li style=""><asp:Label ID="GroupIDLabel" runat="server" Text='<%# Eval("GroupID") %>' Visible="false" />
                            <strong><asp:Label ID="GroupNameLabel" runat="server" Text='<%# Eval("GroupName") %>' /></strong><br />
                            <asp:Label ID="GroupDescriptionLabel" runat="server" Text='<%# Eval("GroupDescription") %>' />
                            <asp:ListView ID="ListView2" runat="server" DataKeyNames="ReportID" DataSourceID="SDS2"
                                ItemPlaceholderID="itemPlaceholderContainer2">
                                <EmptyDataTemplate>
                                </EmptyDataTemplate>
                                <ItemTemplate>
                                    <li style="">
                                        <asp:Label ID="ReportIDLabel" runat="server" Text='<%# Eval("ReportID") %>' />
                                        <br />
                                        <asp:Label ID="ReportNameLabel" runat="server" Text='<%# Eval("ReportName") %>' />
                                    </li>
                                </ItemTemplate>
                                <LayoutTemplate>
                                    <ul id="itemPlaceholderContainer2" runat="server" style="">
                                        <li runat="server" id="itemPlaceholder2" />
                                    </ul>
                                    <div style="">
                                    </div>
                                </LayoutTemplate>
                            </asp:ListView>
                        </li>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <ul id="itemPlaceholderContainer" runat="server" style="">
                            <li runat="server" id="itemPlaceholder" />
                        </ul>
                        <div style="">
                        </div>
                    </LayoutTemplate>
                </asp:ListView>

  <asp:SqlDataSource ID="SDS1" runat="server" ConnectionString="Data Source=mandb02\sqlexpress;Initial Catalog=ManconWeb;User ID=manconweb;Password=passthebox"
                    ProviderName="System.Data.SqlClient" SelectCommand="SELECT [GroupID], [GroupName], [GroupDescription], [Default_Roles_Allow] FROM [RRD_Reports_Groups]">
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="SDS2" runat="server" ConnectionString="Data Source=mandb02\sqlexpress;Initial Catalog=ManconWeb;User ID=manconweb;Password=passthebox"
                    ProviderName="System.Data.SqlClient"
                    SelectCommand="SELECT ReportID, GroupID, ReportName, ReportCreated, ReportUpdated FROM RRD_Reports_List WHERE (GroupID = @GroupID)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GroupIDLabel" Name="GroupID"
                            PropertyName="Text" />
                    </SelectParameters>
                </asp:SqlDataSource>

 

I get the following error: Could not find control 'GroupIDLabel' in ControlParameter 'GroupID'. 

4/1/2011 1:04:37 PM
Gravatar
Total Posts 18439

Re: asp:ListView

The closest example I can think of that is included in mojoPortal source code is in WebStore/WebStore/Controls/ProductListControl.ascx, it uses nested <asp:Repeater controls and you can see how it databinds the inner repeater from within the ItemDataBoundEvent of the outer repeater.

I used a DataSet with 2 DataTables inside it related by relationships, you can see hwo I did it by following the code for store.GetProductPageWithOffers

 

The same concepts should apply for ListView if you really need to use ListView, or you could try using repeater.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.