Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>why don't you use much simpler ways to parse your string to HtmlTableRow.</p> <p>your <code>Dictionary&lt;string, HtmlContainerControl&gt; controlConstructor</code> considers only <code>tr</code> and <code>td</code>, what about input control nested inside them? </p> <p>so even if you get away through that "<code>sequence contains more than one element</code>", using a foreach loop, you will get an error <code>"key doesn't exist</code>".</p> <p>and even if you manage overcome that(by adding input key in your dictionary), you cannot parse it to a <code>HtmlContainerControl</code>. </p> <p>and even if you do, by updating your <code>Dictionary&lt;string, HtmlContainerControl&gt;</code> to <code>Dictionary&lt;string, HtmlControl&gt;</code> , you will have to think of ways to handle that input control because, for that you cannot do <code>control.InnerText = o.value;</code></p> <p>hence a much simpler way:</p> <pre><code>string row = "&lt;tr&gt;&lt;td&gt;item&lt;/td&gt;&lt;td&gt;&lt;input name=\"radio0\" type=\"radio\"/&gt;&lt;/td&gt;&lt;/tr&gt;"; XmlDocument doc = new XmlDocument(); doc.LoadXml(row); HtmlTableRow tblRow = new HtmlTableRow(); foreach (XmlNode node in doc.SelectSingleNode("tr").ChildNodes) { HtmlTableCell cell = new HtmlTableCell(); cell.InnerText = node.InnerXml; foreach (XmlNode childNode in node.ChildNodes) { if (childNode.Name == "input") { if (childNode.Attributes["type"] != null) { switch (childNode.Attributes["type"].Value.ToString()) { case "radio": HtmlInputRadioButton rad = new HtmlInputRadioButton(); rad.Name = childNode.Attributes["name"].ToString(); cell.Controls.Add(rad); break; ///other types of input controls default: break; } } else { HtmlInputButton button = new HtmlInputButton("button"); cell.Controls.Add(button); } } } tblRow.Cells.Add(cell); } </code></pre> <p>as you can see, it is a very rough and strict logic: what best you can do is to come up with a recursive function, to construct your HtmlTableRow</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload