日期:2014-05-17 浏览次数:20522 次
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
public int i;
protected string GetUrl(int i)
{
if (i % 2 == 0)
return "http://t2.gstatic.com/images?q=tbn:ANd9GcSTwunS5WG8coDuWrl4uXkqRpnwYjPzsa5TDzWVBIfCRYYmYV_mgpmpn34";
else
return "http://t2.gstatic.com/images?q=tbn:ANd9GcSvv7bpkq4RbhnU-HsrwWNLpgUT5T-zGT_80WhJnIEfz8LsC4mnN9Fc7s8";
}
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item
------解决方案--------------------
e.Item.ItemType == ListItemType.AlternatingItem)
{
var x = e.Item.DataItem;
var t = x.GetType();
var p = t.GetProperty("i");
i = (int)p.GetValue(x, null);
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<table border="1">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="ObjectDataSource1" OnItemDataBound="Repeater1_ItemDataBound">
<HeaderTemplate>
<tr>
<th>field_1
</th>