p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
I forgot my password Register Now
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 14th, 2007, 03: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;
            }
        }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old July 14th, 2007, 01:09 PM
planoie's Avatar
Friend of Wrox
Points: 16,368, Level: 55
Points: 16,368, Level: 55 Points: 16,368, Level: 55 Points: 16,368, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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

-Peter
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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



All times are GMT -4. The time now is 06:18 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc