你完全可以用Server controls而不用html control,这样可能会有些问题

解决方案 »

  1.   

    你是用下面的方法判断checkbox是否被选中吗?
    CheckBox ckbox=(CheckBox)E.Item.FindControl("Check1");
    if(ckbox!=null)
    {
      ....
    }
      

  2.   

    for(int i=0;i<this.dGrid.Items.Count;i++)
    {
    object findObj = this.dGrid.Items[i].Cells[0].FindControl("chkSel");
    if( ((HtmlInputCheckBox)findObj).Checked )
    {
              }
    }
      

  3.   

    给你一个我的函数:
    public static int[] DgrdChkValue(DataGrid dgrd,string CheckID)
    {
    ArrayList array = new ArrayList(0);
    HtmlInputCheckBox chk = null;
    for(int i=0;i<dgrd.Items.Count;i++)
    {
    chk = (HtmlInputCheckBox)dgrd.Items[i].FindControl(CheckID);
    if(chk.Checked)
    {
    array.Add(chk.Value);
    }
    }

    int[] chkValue = new int[array.Count];
    for(int i=0;i<array.Count;i++)
    {
    chkValue[i] = Int32.Parse(array[i].ToString());
    }
    return chkValue;
    }
      

  4.   

    To littlehb(网际浪子):
      不存在你说的情况。
    我用服务器端的CheckBo试过了,同样的现象。晕~~~我在Page_Load()方法中添加:
      this.btnDelete.Attributes["onclick"] = "javascript:return ConfirmDelete();";
    在页面的javascript中定义:
    function ConfirmDelete(){
        for (var i=0;i<form.elements.length;i++)
        {
    var e = form.elements[i];
    if (e.name != 'chkAll' && e.checked)
    {
      return true;
        }
        }
        return false;
    }
    然后在cs文件中的
    private void btnDel_Click(object sender, System.EventArgs e)
    {
        for(int i=0;i<this.dataGrid.Items.Count;i++)
        {
    object findObj = this.dataGrid.Items[i].Cells[0].FindControl("chkSel");
    if( ((HtmlInputCheckBox)findObj).Checked ) //在此步调试时,发现对象已
                 //经获取并转换,但是Checked始终是false.
    {
                 //执行相关代码
                 ... ...
              }
        }
    }
      

  5.   

    To freecs(北狼):
      谢谢。
    我的系统中有很多类似的页面,其他页面都执行正常,只有这一个页面出现这种情况。
    我将几个页面的代码反复对比,没有发现不正常的地方。我怀疑是不是asp.net不稳定导致这种情况呢。
      

  6.   

    有时候是页面(Html)的问题,可能一点点格式的不严格,就会导致莫名其妙的错误,非常难查,
    你再仔细查查 页面的 Html