regarding string builder(how to display dropdownlist in stringbuilder)

六月ゝ 毕业季﹏ 提交于 2019-12-25 05:26:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!