troubleshooting Question

C# dynamic table cell/rows

Avatar of fm250
fm250Flag for United States of America asked on
.NET ProgrammingC#Editors IDEs
12 Comments1 Solution512 ViewsLast Modified:
what is wron with my table rows/cell. it only display the last var assigined which "summary" from the xml. note that looping through xml is correct.

I know I am not looping correctly. thanks!

Table tbl = new Table();
        tbl.ID = "table1";
        tbl.BorderWidth = 1;

        var xmlDoc = XDocument.Load(new XmlTextReader(Server.MapPath("NewsSrc.xml")));
        foreach (var descendant in xmlDoc.Descendants("NewsItem"))
            TableRow rw = new TableRow();
            TableCell cell = new TableCell();
            var title = descendant.Element("Title").Value;                          
            var summary = descendant.Element("Summary").Value;
            var details = descendant.Element("Details").Value;
            cell.Text = title; 

            cell.Text = summary;

--------------xml -----
    <NewsItem id="1">
        <Title> news tile one </Title>
        <Summary> this is summary to show ....</Summary>
        <Details>details for this news</Details>   

    <NewsItem id="2">
        <Title>test title </Title>
        <Summary>sm line</Summary>
        <Details> no details</Details>    
Jini Jose
Senior .Net Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 12 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros