I have created a dynamic table with stringbuilder. And i got a table with a root element. The requirement is while clicking this root element, the child tables should populate. So how to write the click event for this root table?
I have tried the following code. The onclick event is not firing.
StringBuilder Builder = new StringBuilder();
Builder.Append(@"<table border=1;").Append("id=Tableid;").Append("onclick=GetchildDiv()>").Append("<tr><td>").Append(Mainrow["Title"]).Append("</td></tr></table>");
You need spaces between attributes, not semi-colons (
;). And you should quote the attribute values:Though you could use
AppendFormatinstead, for readability: