zoukankan      html  css  js  c++  java
  • gridview使用技巧

        
    1、CheckBox模板选择事件
    //多选业务员事件 protected void cbSelect_CheckedChanged(object sender, EventArgs e) { string pNames=lblPersonNames.Text; personList = new List<string>(pNames.Split(new string[]{","},StringSplitOptions.RemoveEmptyEntries)); CheckBox cbSelect = (CheckBox)sender; DataControlFieldCell dcf = (DataControlFieldCell)cbSelect.Parent; //父对象Cell GridViewRow gr = (GridViewRow)dcf.Parent; //父对象row if (cbSelect.Checked) { personList.Add(gr.Cells[0].Text); } else { personList.Remove(gr.Cells[0].Text); } lblPersonNames.Text = string.Join(",", personList.ToArray()); }
        
    2、行绑定事件
    protected void gvPerson_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { string pNames = lblPersonNames.Text; personList = new List<string>(pNames.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)); string personName=e.Row.Cells[0].Text; if (personList.Contains(personName)) { CheckBox cbSelect=(CheckBox)e.Row.FindControl("cbSelect"); cbSelect.Checked = true; } } }
       附加:javascript数组扩展方法
    Array.prototype.remove = function(val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } }
  • 相关阅读:
    JQuery移除事件
    .NET经常调用的外部系统函数举例说明
    sql server日期时间转字符串
    关于无法打开微软网站的解决方法[转]
    Html5 第二章
    style、currentStyle、getComputedStyle区别介绍
    删除右键菜单中多余项
    css制作流程及标准
    CSS的选择器
    Mysql 函数集
  • 原文地址:https://www.cnblogs.com/kedarui/p/3894936.html
Copyright © 2011-2022 走看看