Click here to Skip to main content
15,919,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created a xml datasource as under

XML
<Item>
    <id>Motorola Blackflip</id>
    <Description>Motorola Backflip sports a 3.1-inch HVGA capacitive touchscreen</Description>
    <feature>Touchscreen,Wi-Fi,Bluetooth,5 MP Camera,Android OS</feature>
    <price>Rs.18000</price>
    <image>~/Image/Motorola-Backflip.jpeg</image>
  </Item>



and binded with datalist as under

XML
<asp:DataList ID="DataList1" runat="server" Height="498px" Width="566px"
        BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"
        CellPadding="4" ForeColor="Black" GridLines="Vertical" RepeatColumns="2"
        onitemcommand="DataList1_ItemCommand">
        <AlternatingItemStyle BackColor="White" />
        <FooterStyle BackColor="#CCCC99" />
        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
        <ItemStyle BackColor="#F7F7DE" />
    <ItemTemplate>
        <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%#Eval("image")%>'
         Height="150" Width="150" CommandName="product" CommandArgument='<%#Eval("image")%>'/><br />
        <asp:LinkButton ID="LinkButton2" runat="server" Text='<%#Eval("Description") %>'
        CommandName="id" CommandArgument='<%#Eval("id") %>'></asp:LinkButton>

    </ItemTemplate>



now using bubbled event i am reading data and redirecting to some other page as shown bellow

C#
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "product")
        {
            Response.Redirect("ViewProduct.aspx?img=" + e.CommandArgument.ToString());
        }
        else
        {
            Response.Redirect("Description.aspx?de=" + e.CommandArgument.ToString());
        }
    }
}



now in the redirected page i want remaining xml data into some controls like label,image etc.
please help to get remaining data.
Posted
Updated 10-Nov-10 2:23am
v2

1 solution

Code written just for you in free time, Take a look

XmlDocument doc = new XmlDocument();
        doc.Load("");
        XmlNodeList nodeList = doc.GetElementsByTagName("Item");
        foreach (XmlNode node in nodeList)
        {
//Check with respected id value you have got
            if (node["id"].Value == "Motorola Blackflip")
            {
                Panel panel = new Panel();
                foreach (XmlElement element in node)
                {
                
if (element.Name != "image")
                    {
                        Label lbl = new Label();
                        lbl.Text = String.Format("<b>{0}</b>:{1}", element.Name, element.Value); ;
                        panel.Controls.Add(lbl);
                    }
                    else
                    {
                        Image img = new Image();
                        img.ImageUrl = element.Value;
                        panel.Controls.Add(img);
                    }
                }
                Page.Controls.Add(panel);
            }
        }

Please vote and Accept Answer if it Helped.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900