DataList控件实际应用技巧
2010-03-17 18:38 CuiWenKe 阅读(314) 评论(0) 编辑 收藏 举报用Foreach遍历DataListItem
foreach(DataListItem item in DataList1.Items)
{
Label1.Text += ((DataBoundLiteralControl)item.Controls[0]).Text
this.lblDec.Text = ((Label)DataList1.Items[0].FindControl("Lab2Dec")).Text.Trim(); Type(DataList1.items(0).FindControl("id"), controlType).Text
}
DataList绑定事件的时候获取行的索引值
protected void DataListMiddle_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
(e.Item.FindControl("LabMiddleID") as Label).Text = Convert.ToString(e.Item.ItemIndex + 1);
}