问题
Friends
i'm using string builder for generating Passenger List in which i have used a tables i want to add dropdownlist into this Passenger . what i did is i have taken one main table --
strHTML1.Append("<table align=center cellpadding='0' cellspacing='0' width='100%'>");
strHTML1.Append("<tr>");
strHTML1.Append("<td>");
strHTML1.Append("Passenger");
strHTML1.Append("</td>");
strHTML1.Append("</tr>");
strHTML1.Append("<tr>");
strHTML1.Append("<td>");
strHTML1.Append("<asp:dropdownlist id='drp' runat='server' width='140px'>");
strHTML1.Append("</asp:dropdownlist>");
strHTML1.Append("</td>");
strHTML1.Append("</tr>")
.........
the prob is it is not show the dropdownlist when i run the project.
pls help me out to come out from this prob
thanks in advance
回答1:
Use this code as per my knowledge you can add HTML tag using literal.You can do this by :
StringBuilder strHTML1 = new StringBuilder();
strHTML1.Append("<select>");
strHTML1.Append("<Option value = 'volvo'>Volvo</Option>");
strHTML1.Append("<Option value = 'saab'>Saab</Option>");
strHTML1.Append("<Option value = 'mercedes'>Mercedes</Option>");
strHTML1.Append("<Option value = 'audi'>Audi</Option>");
strHTML1.Append("</select>");
and final code is :
strHTML1.Append("<table align=center cellpadding='0' cellspacing='0' width='100%'>");
strHTML1.Append("<tr>");
strHTML1.Append("<td>");
strHTML1.Append("Passenger");
strHTML1.Append("</td>");
strHTML1.Append("</tr>");
strHTML1.Append("<tr>");
strHTML1.Append("<td>");
strHTML1.Append("<select>");
strHTML1.Append("<Option value = 'volvo'>Volvo</Option>");
strHTML1.Append("<Option value = 'saab'>Saab</Option>");
strHTML1.Append("<Option value = 'mercedes'>Mercedes</Option>");
strHTML1.Append("<Option value = 'audi'>Audi</Option>");
strHTML1.Append("</select>");
strHTML1.Append("</td>");
strHTML1.Append("</tr>");
strHTML1.Append("</table>");
来源:https://stackoverflow.com/questions/11097423/regarding-string-builderhow-to-display-dropdownlist-in-stringbuilder