Asp.net stringbuilder usage example code

Source: Internet
Author: User


To achieve the above results CopyCode The Code is as follows: public static string shownewmsg ()
{
String pic1 = "images/yzdp-_15.gif ";
String pic2 = "images/yzdp-_18.gif ";
String pic3 = "images/yzdp-_20.gif ";
String pic4 = "images/yzdp-_22.gif ";
String pic5 = "images/yzdp-_24.gif ";
String pic6 = "images/yzdp-_26.gif ";
String pic7 = "images/yzdp-_28.gif ";
String pic8 = "images/yzdp-_30.gif ";
String pic9 = "images/yzdp-_32.gif ";
String pic10 = "images/yzdp-_34.gif ";
Bjmsginfo info = new bjmsginfo ();
Info. Version = "cn ";
Info. isnew = true;
Datatable dt = WebManager. list (Info, "bjuserinfomsg", "Top 10 userid, title, usertitle, usertype, yzfd, companyName, yzpl, yzfw, yzzl, userpic, comments, createtime, msginfo, category ", "& isnew", "[orderno]");
Stringbuilder builder = new stringbuilder ();
If (Dt. Rows. Count> 0)
{
For (INT I = 0; I <DT. Rows. Count; I ++)
{
Builder. append ("<Table width = '000000' border = '0' cellspacing = '0' cellpadding = 0'> <tr> ");
Builder. append ("<TD width = '6% 'align = 'left' valign = 'middle'> ");
Builder. append ("If (I = 0)
{
Builder. appendformat ("src = '{0}'", pic1 );
}
Else if (I = 1)
{
Builder. appendformat ("src = '{0}'", pic2 );
}
Else if (I = 2)
{
Builder. appendformat ("src = '{0}'", pic3 );
}
Else if (I = 3)
{
Builder. appendformat ("src = '{0}'", pic4 );
}
Else if (I = 4)
{
Builder. appendformat ("src = '{0}'", pic5 );
}
Else if (I = 5)
{
Builder. appendformat ("src = '{0}'", pic6 );
}
Else if (I = 6)
{
Builder. appendformat ("src = '{0}'", pic7 );
}
Else if (I = 7)
{
Builder. appendformat ("src = '{0}'", pic8 );
}
Else if (I = 8)
{
Builder. appendformat ("src = '{0}'", pic9 );
}
Else if (I = 9)
{
Builder. appendformat ("src = '{0}'", pic10 );
}
Builder. append ("width = '15' Height = '12'/> ");
Builder. append ("</TD> <TD width = '000000' align = 'left' valign = 'middle'> ");
// <A href = "qbdp. aspx? CompanyName = <% # eval ("href =" qbdp. aspx? CompanyName = <% # eval ("companyName") %> "> <% # eval (" companyName ") %> </a>
Builder. append ("<a href = ");
Builder. append ("href = ");
Builder. append ("qbdp. aspx? ");

Builder. appendformat ("companyName = '{0}'", DT. Rows [I] [5]. tostring ());

Builder. append ("</a> ");
Builder. appendformat ("{0}", DT. Rows [I] [5]. tostring ());
Builder. append ("</TD> </tr> </table> ");
}

}
Return builder. tostring ();
// Dlnewmsginfo. datasource = DT. defaultview;
// Dlnewmsginfo. databind ();
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.