zoukankan      html  css  js  c++  java
  • gridview 后台增加列

    BoundField field1 = null;

    field1 = new BoundField();  //实例化

    field1.HeaderText = "序号";
    field1.HeaderStyle.Width = new Unit(40, UnitType.Pixel);
    field1.ItemStyle.CssClass = "GridViewClo";

    GridView1.Columns.Add(field1); //增加列

     

    //把模板列谢伟一般列 BoundField 导入事件

    //还是行上面一样先搭一个BoundField 

    然后在GridView1_RowDataBound事件中加列的事件

    for (int i = 0; i < GridView1.Columns.Count; i++)
    {
    DataControlField dcf = GridView1.Columns[i];

    if (dcf.HeaderText.IndexOf("班主任评语") == 0)
    {
    string sqlpingyu = "select Commentpingyu from base_comment where Stu_code= '" + e.Row.Cells[1].Text + "'";
    string Commentpingyu = DataBase.Exec(sqlpingyu);

    string xueqi = "select termxueqi from base_comment where Stu_code= '" + e.Row.Cells[1].Text + "'";
    string termxueqi = DataBase.Exec(xueqi);
    if (termxueqi == "")
    {

    //学期
    string xueqimax = "select top 1 Key_number from Base_DbKey where Key_parentnumber='000028' order by key_name desc ";
    termxueqi = DataBase.Exec(xueqimax); 
    }

    e.Row.Cells[i].Text = "<input type="button" id="btndead" title="编辑" class="btndead" style=" 17px; height:15px;background:url(../../Images/blue/2014/pin.png);" onclick="guestedit(this,'" + i + "','" + e.Row.Cells[1].Text + "','" + termxueqi + "','" + Commentpingyu + "')" />";

    }

    }

     

    在看看前台的事件:

    function guestedit(obj, numbers, code,termxueqi, Commentpingyu) {
    // var sel = document.getElementById('ddl_xq');
    // var ddlcode = sel.options[sel.selectedIndex].value;
    Window_Open(obj, 1, '../student/studentcommentAdd.aspx?numbers=' + numbers + '&code=' + code + '&DDL=' + termxueqi + '&Commentpingyu=' + Commentpingyu, 600, 400);
    }

  • 相关阅读:
    Linux环境下安装JDK
    CentOS 7 更改主机名
    Find Pivot Index之Python实现
    MySQL基本操作之数据库基本操作
    Linux环境下安装单实例MySQL 5.7
    基于时间的ACL配置
    动态ACL的配置
    自反ACL
    OSFPv3的配置
    RIPng 配置
  • 原文地址:https://www.cnblogs.com/panmy/p/5139687.html
Copyright © 2011-2022 走看看