• 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);
    }

  • 相关阅读:
    opencv ImportError: libSM.so.6: cannot open shared object file: No such file or directory
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcd
    Linux卸载并更新显卡驱动
    人脸识别
    dav转mp4
    python调用c++接口,参数为opencv读取数据
    Linux下内存泄漏工具valgrind
    模型轻量化
    自动驾驶车搭建
    TSN(Temporal Segment Networks)
  • 原文地址:https://www.cnblogs.com/panmy/p/5139687.html
Copyright © 2020-2023  润新知