Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i got some help from a guy in here to help me create my basket. and it works fine with my node set called addons, the problem is that i need to get another set of nodes into my basket and counting them with addons. And i all works fine exept that under my noe Rooms it only count the last element. my code where i give my nodes id.
XML
int id = 0;
foreach (XmlNode Beboer in xmlDokument.GetElementsByTagName("Room"))
{


    litResultat.Text += @"<table class='table-responsive'><tr>"
    + "<td style='margin-left:2%'>" + "<input  style='text-align: center;outline: 0;border-radius:10px; box-shadow: 2px 2px 1px #888888; height: 35px;  width: 50px;' placeholder='&nbsp;Antal' name='txtRoomAntal" + id + "' id='txtRoomAntal" + id + "'" + "data-role='none' type='text' />" + "</td>"
    + "<td style='text-align:left;'>" + Beboer["RoomText"].InnerText + "&nbsp;</td>"
    + "<td style='text-align:right;'>" + Beboer["RoomPrice"].InnerText  + "&nbsp;kr</td>"
    + "<td style='text-align:right;'>" + "<i style=' font-family: times, Times New Roman, times-roman, georgia, serif;font-size: 20px;line-height: 40px;letter-spacing: -1px;color: #444;margin: 0 0 0 0;padding: 0 0 0 0;font-weight: 500;'>" + Beboer["RoomPriceOffersText"].InnerText +  Beboer["RoomPriceOffers"].InnerText + "</i></td>"
    + "<td>" + "<input style='display:none; border:none; box-shadow: none;' type='text' value='" + Beboer["RoomType"].InnerText + "' name='txtRoomType" + id + "' id='txtRoomType" + id + "'>" + "</input>" + "</td>"
    + "</tr>"
    + "</table>";

    id++;
}



and the code where i put them into my basket and counting

var allRoomNodes = doc.SelectNodes("TourInfo/Rooms/Room");
       if (allRoomNodes == null)
           return;

       for (int x1 = 0; x1 < allRoomNodes.Count; x1++)
       {
           //create a new table row
           HtmlTableRow row = new HtmlTableRow();
           // a cell instance to add to the row.
           HtmlTableCell cell;

           string textBoxRoomname = string.Format("txtRoomAntal{0}", x1);

           XmlNode roomNode = allRoomNodes[x1];
           //Error handling
           if (roomNode["RoomPrice"] == null)
               continue;

           //Error handling
           int antal;
           if (!int.TryParse(Request.Form[textBoxRoomname], out antal))
               continue;

           //Error handling
           int pris;
           if (!int.TryParse(roomNode["RoomPrice"].InnerText, out pris))
               continue;

           var ansver = antal * pris;
           total += ansver;


           var nodeARoomText = roomNode["RoomText"];

           string nodeAInnerText = nodeARoomText == null ? "" : nodeARoomText.InnerText;

           cell = new HtmlTableCell();
           cell.InnerText = nodeAInnerText;
           row.Cells.Add(cell);

           cell = new HtmlTableCell();
           cell.InnerText = antal.ToString();
           row.Cells.Add(cell);

           cell = new HtmlTableCell();
           cell.InnerText = string.Format("Pris:{0}kr", ansver);
           row.Cells.Add(cell);

           //add the row to the table
           table.Rows.Add(row);

       }

C#
table.RenderControl(writer);

       litAdd.Text = sb.ToString();

       litTotal.Text = total + @"&nbsp;kr";
Posted

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