为什么Gridview计数为零 [英] Why Gridview Count Zero

查看:91
本文介绍了为什么Gridview计数为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void DeleteLateAttendance()
        {
            LateAttendanceRepository LateRepository = new LateAttendanceRepository();
            LateAttendanceApprovalDto LateApprovalDto = new LateAttendanceApprovalDto();
            int count = grdLateAttendance.Rows.Count;
            foreach (GridViewRow gvRow in grdLateAttendance.Rows)
            {
                CheckBox chk = gvRow.FindControl("chkDelete") as CheckBox;
                if (chk != null && chk.Checked)
                {
                    LateApprovalDto.LateAttendanceApprovalID= gvRow.Cells[1].Text.Trim();
                    LateRepository.DeleteLateAttendance(LateApprovalDto.LateAttendanceApprovalID);
                }

            }
        }


此网格视图计数为零.但是网格视图包含3行.


This grid view count zero.but grid view contain 3 rows.

推荐答案

调用您在pageload的!ispostback中的bindGrid方法看到网格绑定是否完全完成了吗?绑定网格时应该存在问题,一个或多个列一定不能绑定到网格,然后碰巧数据集将具有3行,但绑定后没有网格...
call Your bindGrid method in !ispostback of pageload and see is the grid binding completely??? there should be problem in binding grid one or more column must not be binded to grid then it happends dataset would have 3 rows but not grid have after binding...


这篇关于为什么Gridview计数为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆