小弟我在一个网页中加入了datagrid件,用模版把一列设定为checkbox副选框,
当选中一个时,怎么能够返回datagrid的行号呢?????

解决方案 »

  1.   

    边历datagrid
    判断哪一行的checkbox被选中,这样就可以找到了
      

  2.   

    捕捉 dataGri 的 MouseDown 以当前X,Y 
    用 DataGrid.HitTest
    找到选中的 单元格  
     用.row() 就OK了
      

  3.   

    public static string CountIsChecked(DataGrid itemgrid ,string Controlid,string str)
    {
    string StrId="";
    foreach(DataGridItem item in itemgrid.Items)
    {
    CheckBox che=new CheckBox ();
    che=(CheckBox)item.FindControl (Controlid);
    if (che.Checked)
    {
    if (str=="1")
    {
    StrId=che.CssClass;
    return StrId ;
    }
    if (str=="2")
    {
    StrId =StrId+che.CssClass+","; 
    }
    } }
    return StrId; }
      

  4.   

    如果你是用datagrid和checkbox做选择题的话,
    你可以搜索一下过去的帖子
    很多的
      

  5.   

    <asp:label id=Lindex runat=server visible=false text=<%#(int)DataBinder.Eval(Container.Item,"ItemIndex")+1%>  />取Lindex的值
      

  6.   

    SERVER CONTROL:  
     CheckBox    che=(CheckBox)item.FindControl ("NAME");
    if(che!=null)
    {
        che.checked????????
    }
    HTML CONTROL:
      REQUSET.PARMS("NAME"); 得到的是VALUE值,必须设定NAME属性
      

  7.   

    private bool CheckdCB
    {
    bool result =true; 
    for(int i=0;i<this.DataGrid1.Items.Count;i++)
    {
        CheckBox CB=new CheckBox ();
        CB=(CheckBox)item.FindControl("your CheckBoxName");
      if{
          CB.Checked ==true;
          result = ture;
          return result;
        }
      else
        {
          result = false;
          return result;
        }
    }
    return result;
    }