RT ,在线等

解决方案 »

  1.   

    protected void grdview_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
          int index=e.RowIndex;
    }
    是这意思吗?
    其实关键是,你的按钮是什么按钮,类似更新,编辑,取消,选择的按钮时可以这么做的。
    如果是其他的,则可以先加个选择按钮,在加自己的按钮,然后再通过JS去绑定这两个按钮,则也可以得到e.NewSelectedIndex
      

  2.   

    GridView1.Rows[GridView1.EditIndex]GridView1.EditIndex获取行号
      

  3.   

    不知LZ要的是c#还是js
    c#:ls
    js:可给button或者row起个ID,获取其ID既可获得行号
      

  4.   

    命名此按钮的CommandName为btnAdd
    然后在GridView的Command事件里写
    if(e.Command =="btnAdd")
    {
    你想写的代码
    int row = Decimal.Prase(e.CommandArgument);获取行号
    }
    这样就行了``
      

  5.   

    首先你给给你的gridView模板列中button设置其CommandName,eg <asp:Button ID="Button2" CommandName="Command2" runat="server" Text="Command2"  />然后再通过在 protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    函数当中去捕捉这个点击事件
    参考protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {      int rowIndex = -1;
          GridViewRow row = null;        
          if(e.CommandName=="Command2") {
             // 直接获取当前的 GridViewRow
             Control cmdControl = e.CommandSource as Control; // 表示触发事件的 IButtonControl,保持统一性并便于后续操作,我们这里直接转化为控件基类 Control
             row = cmdControl.NamingContainer as GridViewRow;//取得其控件所在的行
             Response.Write(row.RowIndex);//输入其行号.
    }
      

  6.   

    Button的客户端事件设置为:
    '<script>alert(<%# Container.DataItemIndex + 1%>);</script>'
    就可以了。
      

  7.   

    symbol441(≮西门潇洒≯) 
    你好:
    我怎么必须是LinkButton才行,而Button 不行啊,报页面级错误,而且也不进protected   void   GridView1_RowCommand(object   sender,   GridViewCommandEventArgs   e) 
    函数里
      

  8.   

    因为LinkButton有CommandName,Button没有