int l = 0;
for (int i = 0; i <= count; i++)
{
int currentTop = begin_top - i * step;
bool flag = currentTop != 0;
begin_html += string.Format(@"<span style=""padding-top:{0}px;"">", currentTop); for (int j = 0; j <= i; j++)
{
try
{
begin_html += string.Format(@"<img src=""{0}""/>", dt.Rows[l]["HomeImgUrl"]);
}
catch
{ }
l++;
}
begin_html += "</span>";
}以上是一个嵌套循环,要通过l索引某行的数据并显示,目前是通过try catch解决的,我试了下面的方法行不通
if (!dt.Rows[l].IsNull(0))
begin_html += string.Format(@"<img src=""{0}""/>", dt.Rows[l]["HomeImgUrl"]);不知道应该怎样判断某个datarow不存在或为空。
{
...
}