<div>
方案1
<%for (int i = 0; i < art_hot.Count; i++)
{%>
<%if (i == 0)
{%>
<td>
ok<%=art_hot[i].Name%>
</td>
<%}
else
{ %>
<td>
<%=art_hot[i].Name%>
</td>
<%} %>
方案2
<%} %>
<%foreach (var r in art_hot)
{ %>
<%if (r.Index == 0)
{ %>
<td>
ok<%=r.Name%>
</td>
<%}
else
{ %>
<td>
<%=r.Name%>
</td>
<%} %>
<%} %>
</div>
public class Article
{
private string name;
public string Name
{
get { return name; }
set { name = value; }
}
private int index;
public int Index
{
get { return index; }
set { index = value; }
}
}
public partial class _Default : System.Web.UI.Page
{
protected IList<Article> art_hot = null;
protected void Page_Load(object sender, EventArgs e)
{
art_hot = new List<Article>();
art_hot.Add(new Article() { Index = 0, Name = "1" });
art_hot.Add(new Article() { Index = 1, Name = "1" });
art_hot.Add(new Article() { Index = 2, Name = "1" });
art_hot.Add(new Article() { Index = 3, Name = "1" });
art_hot.Add(new Article() { Index = 4, Name = "1" });
}
}
浙公网安备 33010602011771号