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

       /// <summary>
        
    /// 编辑选中事件
        
    /// </summary>
        
    /// <param name="sender"></param>
        
    /// <param name="e"></param>

        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        
    {
            GridView1.EditIndex 
    = e.NewEditIndex;
            databinGrid();
        }


        
    /// <summary>
        
    /// 编辑取消事件
        
    /// </summary>
        
    /// <param name="sender"></param>
        
    /// <param name="e"></param>

        protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
        
    {
            GridView1.EditIndex 
    = -1;
            databinGrid();
        }


        
    /// <summary>
        
    /// 更新事件
        
    /// </summary>
        
    /// <param name="sender"></param>
        
    /// <param name="e"></param>

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        
    {
            bbsjhwType.Id 
    = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
            bbsjhwType.Name 
    = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
            bbsjhwType.Update();
            GridView1.EditIndex 
    = -1;
            databinGrid();
        }


        
    /// <summary>
        
    /// 设置textbox宽度
        
    /// </summary>
        
    /// <param name="sender"></param>
        
    /// <param name="e"></param>

        protected void GridView1_PreRender(object sender, EventArgs e)
        
    {
            
    if (GridView1.EditIndex > -1)
            
    {
                TextBox TXTb 
    = new TextBox();
                
    for (int i = 1; i < 2; i++)
                
    {
                    TXTb 
    = (TextBox)GridView1.Rows[GridView1.EditIndex].Cells[i].Controls[0];
                    TXTb.Width 
    = 50;
                }

            }

        }

        
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        
    {
            bbsjhwType.Id 
    = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
            bbsjhwType.Delete(bbsjhwType.Id);
            databinGrid();
        }

        
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        
    {
            
    //如果是绑定数据行 
            if (e.Row.RowType == DataControlRowType.DataRow)
            
    {
                
    if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
                
    {
                    ((LinkButton)e.Row.Cells[
    3].Controls[0]).Attributes.Add("onclick""javascript:return confirm('你确认要删除:\"" + e.Row.Cells[1].Text + "\"吗?它相应的子类将也被删除')");
                }

            }

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            databinGrid();
        }

    供大家复制.
  • 相关阅读:
    Python 命令模式和交互模式
    Python自带IDE设置字体
    Python2.7和3.7区别
    Kubernetes1.91(K8s)安装部署过程(八)-- kubernetes-dashboard安装
    Kubernetes1.91(K8s)安装部署过程(七)--coredns安装
    nginx 设置自签名证书以及设置网址http强制转https访问
    Kubernetes1.91(K8s)安装部署过程(六)--node节点部署
    VMware安装VMware tool是 遇到The path "" is not a valid path to the 3.10.0-693.el7.x86_64 kernel headers.
    第三方git pull免密码更新
    Kubernetes1.91(K8s)安装部署过程(五)--安装flannel网络插件
  • 原文地址:https://www.cnblogs.com/daxia/p/797752.html
Copyright © 2011-2022 走看看