日期:2014-05-17 浏览次数:20571 次
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
string str=(this.DataList1.Items[e.Item.ItemIndex].FindControl("lblCommentNumber") as Label).Text;
}
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<asp:Label ID="lblCommentNumber" runat="server" Text='<%#CommentsNumber %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
string str = (e.Item.FindControl("lblCommentNumber") as Label).Text;
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem
------解决方案--------------------
e.Item.ItemType == ListItemType.Item)
{
if (e.Item.FindControl("lblCommentNumber") != null)
{
Label lbl = (Label)e.Item.FindControl("lblCommentNumber");
string str = lbl.Text;