asp.net 的foreach 在ASP里怎么用? 30
asp.net代码publicstringgetbbs(){sid=Convert.ToInt32(Request.QueryString["id"]);StringBu...
asp.net代码
public string getbbs()
{
sid = Convert.ToInt32(Request.QueryString["id"]);
StringBuilder str = new StringBuilder();
foreach (DataRow var in SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, "select id,sclassName,bClassID from smallclass where bclassid='"+sid+"'", null).Tables[0].Rows)
{
str.Append("<table class='table' width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"top\">");
str.Append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>");
str.Append("<td height=\"30\"width=\"123\" align=\"center\"> <strong>" + var["sclassName"].ToString() + "</td>");
str.Append("<td width=\"330\" align='right'><a href=\"bbs/showforum-" + var["bClassID"].ToString() + ".aspx\" target=\"_blank\">更多>>></a></td></tr></table>");
foreach (DataRow var1 in SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, "select * from article where sclassID='" + var["id"] + "'", null).Tables[0].Rows)
{
str.Append(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; height: 100%\"><tr><td style=\"width: 100%\"><span style=\"float:right; margin-right:30px\">" + var1["compose_date"] + "</span>");
str.Append(" <a href=\"news" + var1["id"].ToString() + "\" target=\"_blank\">");
str.Append((var1["title"].ToString().Length > 13 ? var1["title"].ToString() + "..." : var1["title"].ToString())
+ "</a></td></tr></table>");
}
str.Append(" </td><td width=\"10\" align=\"center\" valign=\"middle\">");
str.Append(" <img src=\"default ertical-line.gif\" width=\"1\" height=\"212\" />");
str.Append("</td></tr></table>");
}
return str.ToString();
} 展开
public string getbbs()
{
sid = Convert.ToInt32(Request.QueryString["id"]);
StringBuilder str = new StringBuilder();
foreach (DataRow var in SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, "select id,sclassName,bClassID from smallclass where bclassid='"+sid+"'", null).Tables[0].Rows)
{
str.Append("<table class='table' width=\"500\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td align=\"left\" valign=\"top\">");
str.Append("<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>");
str.Append("<td height=\"30\"width=\"123\" align=\"center\"> <strong>" + var["sclassName"].ToString() + "</td>");
str.Append("<td width=\"330\" align='right'><a href=\"bbs/showforum-" + var["bClassID"].ToString() + ".aspx\" target=\"_blank\">更多>>></a></td></tr></table>");
foreach (DataRow var1 in SqlHelper.ExecuteDataSet(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, "select * from article where sclassID='" + var["id"] + "'", null).Tables[0].Rows)
{
str.Append(" <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"width: 100%; height: 100%\"><tr><td style=\"width: 100%\"><span style=\"float:right; margin-right:30px\">" + var1["compose_date"] + "</span>");
str.Append(" <a href=\"news" + var1["id"].ToString() + "\" target=\"_blank\">");
str.Append((var1["title"].ToString().Length > 13 ? var1["title"].ToString() + "..." : var1["title"].ToString())
+ "</a></td></tr></table>");
}
str.Append(" </td><td width=\"10\" align=\"center\" valign=\"middle\">");
str.Append(" <img src=\"default ertical-line.gif\" width=\"1\" height=\"212\" />");
str.Append("</td></tr></table>");
}
return str.ToString();
} 展开
3个回答
展开全部
set rs=server.CreateObject("adodb.recordset")
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ("数据库连接字符串")
rs.open "sql语句",conn,1,1
do while not rs.eof
response.write "" '这里写上输出的语句
rs.movenext
loop
使用do while方法输出所有的数据库记录,
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ("数据库连接字符串")
rs.open "sql语句",conn,1,1
do while not rs.eof
response.write "" '这里写上输出的语句
rs.movenext
loop
使用do while方法输出所有的数据库记录,
参考资料: 361度搜索 为您解答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我这个容易懂一点:
foreach (GridViewRow gvr in gvStudentScores.Rows)
{
for (int i = 0; i < totalCount; i++)
{
int assignmentID = System.Convert.ToInt16(gvr.Cells[0].Text);
int evaluateItemID = int.Parse(gvStudentScores.Columns[4 + i].FooterText);
string score = ((TextBox)gvr.Cells[i].FindControl("txtScore" + (i + 4).ToString())).Text;
DalSubmitScore(assignmentID, evaluateItemID, decimal.Parse(score));
}
}
foreach (GridViewRow gvr in gvStudentScores.Rows)
{
for (int i = 0; i < totalCount; i++)
{
int assignmentID = System.Convert.ToInt16(gvr.Cells[0].Text);
int evaluateItemID = int.Parse(gvStudentScores.Columns[4 + i].FooterText);
string score = ((TextBox)gvr.Cells[i].FindControl("txtScore" + (i + 4).ToString())).Text;
DalSubmitScore(assignmentID, evaluateItemID, decimal.Parse(score));
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
for next
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询