统计DataList 的某个列值等于1的记录
protected void DataList_Hu_ItemDataBound(object sender, DataListItemEventArgs e)
    {         
        Label GuanXi_Name_H = (Label)e.Item.FindControl("lab_GuanXi_Name_H");
        if (GuanXi_Name_H.Text == "户主")
            iCount++;       
       
    }得到的iCount 不对,为什么

解决方案 »

  1.   


     protected void DataList_Hu_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Label GuanXi_Name_H = (Label)e.Item.FindControl("lab_GuanXi_Name_H");
                if (GuanXi_Name_H.Text == "户主")
                    iCount++;
            }    } 
      

  2.   

     tongkai1206的答案也不对啊我的DataList_Hu是分页的,PagedDataSource 分的页