.net中datatable中随机取一个数据,怎样让它跟自身的datatable一列数据比较??
datatable中随机取一个数据,怎样让它跟自身的datatable一列数据比较??我下面写只能比较前后的数据,那应该怎样使它比较所有数据?for(inti=0;i<d...
datatable中随机取一个数据,怎样让它跟自身的datatable一列数据比较??我下面写只能比较前后的数据,那应该怎样使它比较所有数据?
for (int i = 0; i < dtTuPian.Rows.Count; i++)
{
string FileName = dtTuPian.Rows[i]["FileName"].ToString();
string url = dtTuPian.Rows[i]["FileUrl"].ToString();
if (i == 0)
{
if (!url.Contains("http"))
url = "http://" + url;
sbPic.Append("<li>");
sbPic.Append("<a href=\"#\">");
sbPic.Append(" <img src=\"" + url
+ "\" width=\"280\" height=\"365\">");
sbPic.Append(" <img src=\"img/shangbiao.jpg\" /><strong>" + dtTuPian.Rows[i]["FileName"].ToString()
+ "</strong><span></span>");
sbPic.Append("</a>");
sbPic.Append("</li>");
}
else
{
if (FileName != dtTuPian.Rows[i - 1]["FileName"].ToString())
{
//return null;
if (!url.Contains("http"))
url = "http://" + url;
sbPic.Append("<li>");
sbPic.Append("<a href=\"#\">");
sbPic.Append(" <img src=\"" + url
+ "\" width=\"280\" height=\"365\">");
sbPic.Append(" <img src=\"img/shangbiao.jpg\" /><strong>" + FileName
+ "</strong><span></span>");
sbPic.Append("</a>");
sbPic.Append("</li>");
}
}
} 展开
for (int i = 0; i < dtTuPian.Rows.Count; i++)
{
string FileName = dtTuPian.Rows[i]["FileName"].ToString();
string url = dtTuPian.Rows[i]["FileUrl"].ToString();
if (i == 0)
{
if (!url.Contains("http"))
url = "http://" + url;
sbPic.Append("<li>");
sbPic.Append("<a href=\"#\">");
sbPic.Append(" <img src=\"" + url
+ "\" width=\"280\" height=\"365\">");
sbPic.Append(" <img src=\"img/shangbiao.jpg\" /><strong>" + dtTuPian.Rows[i]["FileName"].ToString()
+ "</strong><span></span>");
sbPic.Append("</a>");
sbPic.Append("</li>");
}
else
{
if (FileName != dtTuPian.Rows[i - 1]["FileName"].ToString())
{
//return null;
if (!url.Contains("http"))
url = "http://" + url;
sbPic.Append("<li>");
sbPic.Append("<a href=\"#\">");
sbPic.Append(" <img src=\"" + url
+ "\" width=\"280\" height=\"365\">");
sbPic.Append(" <img src=\"img/shangbiao.jpg\" /><strong>" + FileName
+ "</strong><span></span>");
sbPic.Append("</a>");
sbPic.Append("</li>");
}
}
} 展开
展开全部
List <string> ls = new List <string>(); //存放你一整列所有的值
DataTable dt = new DataTable();
foreach (DataRow dr in dt.Rows)
{
ls.Add(dr["列名"]);
}
DataTable dt = new DataTable();
foreach (DataRow dr in dt.Rows)
{
ls.Add(dr["列名"]);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询