zoukankan      html  css  js  c++  java
  • GridView中的GridView1_RowCommand事件

    GridView1_RowCommand事件是GridView中生成事件时激发

    比如说页面中有一个按钮给他设置CommandName属性

    <asp:Button ID="btnCheHui" runat="server" class="btn btn-primary" Text="撤回流程" OnClientClick="return confirm('你确定要撤回流程吗')"  CommandName="CheHui" />

    那么在后置代码中的GridView1_RowCommand事件中:

     protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
     {

        //得到选中行的索引
                GridViewRow gvr = (GridViewRow)((Button)e.CommandSource).Parent.Parent;
                int autoId = Convert.ToInt32(this.GridView1.DataKeys[gvr.RowIndex].Value);

        

        //判断当前的按钮命令

        if (e.CommandName == "CheHui")
                {

            //根据获取到的主键autoId值修改数据

        }
                 

      GridView1_RowCommand中取到GridView中其他值:

    获取第一个值  string zhi = GridView1.Rows[gvr.RowIndex].Cells[0].Text;

    获取主键的值  int id = Convert.ToInt32(e.CommandArgument.ToString());

  • 相关阅读:
    织梦开发——相关阅读likeart应用
    织梦标签教程
    织梦专题调用代码
    HIT 2543 Stone IV
    POJ 3680 Intervals
    HIT 2739 The Chinese Postman Problem
    POJ 1273 Drainage Ditches
    POJ 2455 Secret Milking Machine
    SPOJ 371 Boxes
    HIT 2715 Matrix3
  • 原文地址:https://www.cnblogs.com/yuanyanyan/p/5412589.html
Copyright © 2011-2022 走看看