Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 14th, 2007, 02:53 AM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help me with repeater control?

Anyone can help me. The following is problem.
I want create a navigation menu depend on file XML datasource?

I want use Nested Repeater and XML Data create a menu as:
[list]

<li>AAAA</li>[list]
<li>aaa</li>
<li>aaa</li>[list]
<li>BBBB</li>[list]
<li>bbbb</li>
</ul>
</ul>

<?xml version="1.0" encoding="utf-8" ?>
<Data>
    <MenuItem>
        <ID>1</ID>
        <ParentID>0</ParentID>
        <Icon></Icon>
        <Text>AA</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>2</ID>
        <ParentID>1</ParentID>
        <Icon></Icon>
        <Text>aaa</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>3</ID>
        <ParentID>1</ParentID>
        <Icon></Icon>
        <Text>aaaaa</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>4</ID>
        <ParentID>1</ParentID>
        <Icon></Icon>
        <Text>aaaa</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>5</ID>
        <ParentID>1</ParentID>
        <Icon></Icon>
        <Text>aaaaa</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>6</ID>
        <ParentID>0</ParentID>
        <Icon></Icon>
        <Text>BBBBB</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>7</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>8</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>9</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbbbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>10</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>11</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>12</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>13</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>14</ID>
        <ParentID>6</ParentID>
        <Icon></Icon>
        <Text>bbb</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftChildMenuItem</CssClass>
    </MenuItem>
    <MenuItem>
        <ID>15</ID>
        <ParentID>0</ParentID>
        <Icon></Icon>
        <Text>CCCCC</Text>
        <NavigatiorUrl></NavigatiorUrl>
        <CssClass>MLeftMenuItem</CssClass>
    </MenuItem>
</Data>

My code:
<div id="navigation">
                [list]


                    <asp:Repeater runat="server" ID="menu" >
                        <ItemTemplate>
                            <li>
                                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="....."><%# If(eval("parentID")==0) eval("Name") %></asp:HyperLink>

                                <asp:Repeater ID="Repeater1" runat="server" >
                                    <HeaderTemplate>
                                        [list]
                                    </HeaderTemplate>

                                    <ItemTemplate>
                                        <li>
                                            <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="...."><%# Eval("Name") %></asp:HyperLink>
                                        </li>
                                    </ItemTemplate>

                                    <FooterTemplate>
                                        </ul>
                                    </FooterTemplate>
                                </asp:Repeater>
                            </li>
                        </ItemTemplate>
                    </asp:Repeater>
                </ul>


            </div>

behin code:

private string xmlSource = string.Empty;

        protected void Page_Load(object sender, System.EventArgs e)
        {
            rptMenu.DataSource = GetMenu();
            rptMenu.DataBind();
        }

        private ArrayList GetMenu()
        {
            try
            {
                xmlSource = lblXmlSource.Text;
                xmlSource = Server.MapPath(xmlSource);
                XmlDocument doc = new XmlDocument();
                doc.Load(xmlSource);

                ArrayList menu = new ArrayList();

                XmlNodeList list = doc.SelectNodes("Data/MenuItem");
                foreach (XmlNode node in list)
                {
                    try
                    {
                        int id = int.Parse(node.SelectSingleNode("ID").InnerText);
                        string name = node.SelectSingleNode("Text").InnerText;
                        int parentID = int.Parse(node.SelectSingleNode("ParentID").InnerT ext);
                        string cssClass = node.SelectSingleNode("CssClass").InnerText;
                        MenuItems item = new MenuItems(id, parentID, name, cssClass, string.Empty, true);
                        menu.Add(item);
                    }
                    catch
                    {
                        continue;
                    }
                }

                return menu;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
Reply With Quote
  #2 (permalink)  
Old July 14th, 2007, 12:09 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What about using the asp:xml control with an XSL transformation?

-Peter
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
repeater control akssmv ASP.NET 2.0 Basics 1 August 20th, 2008 08:55 PM
Repeater Control Dhanapal General .NET 0 April 2nd, 2007 04:50 AM
Repeater control. rupen ASP.NET 1.0 and 1.1 Basics 1 October 14th, 2005 08:34 AM
Repeater Control abdul_owiusa General .NET 0 August 30th, 2005 04:54 PM
Repeater Control Dmitriy Pro VB 6 0 July 27th, 2004 11:13 AM



All times are GMT -4. The time now is 11:51 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.