asp.net StringBuilder的用法 執行個體代碼

來源:互聯網
上載者:User


要實現上述效果 複製代碼 代碼如下: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='100%' border='0' cellspacing='0' cellpadding=0'> <tr>");
Builder.Append("<td width='6%' align='left' valign='middle'>");
Builder.Append("<img ");
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='94%' 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();
}

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.