protected void dlShop_ItemDataBound(object sender, DataListItemEventArgs e) { #region 分页及嵌套datalist显示 if (e.Item.ItemType == ListItemType.Footer) { Label lblCurrent = e.Item.FindControl("lblCurrentPage") as Label; Label lblCount = e.Item.FindControl("lblCount") as Label; LinkButton lbtnFirst = e.Item.FindControl("lbtnFirst") as LinkButton; LinkButton lbtnPre = e.Item.FindControl("lbtnPre") as LinkButton; LinkButton lbtnNext = e.Item.FindControl("lbtnNext") as LinkButton; LinkButton lbtnLast = e.Item.FindControl("lbtnLast") as LinkButton; lblCurrent.Text = "第" + (pds.CurrentPageIndex + 1).ToString() + "页"; lblCount.Text = "共" + pds.PageCount.ToString() + "页"; if (pds.IsFirstPage) { lbtnFirst.Enabled = false; lbtnPre.Enabled = false; } if (pds.IsLastPage) { lbtnNext.Enabled = false; lbtnLast.Enabled = false; } } else { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { DataList dlPhoneInShop = (DataList)e.Item.FindControl("dlPhoneInShop"); string ShopId = dlShop.DataKeys[e.Item.ItemIndex].ToString().Trim(); shop_phone_byshopid_view1TableAdapter phoneDA = new shop_phone_byshopid_view1TableAdapter(); DataTable phoneDT = phoneDA.Getphoneinfobyid(long.Parse(ShopId)); if (phoneDT.Rows.Count > 0) { dlPhoneInShop.DataSource = phoneDT; dlPhoneInShop.DataBind(); } } } #endregion }