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); } }
  • 相关阅读:
    P4294 [WC2008]游览计划(斯坦纳树)
    CF1056E Check Transcription(SA)
    CF1391D 505(状压dp+思维)
    CF56E Domino Principle(BIT+dp)
    P3402 可持久化并查集
    可持久化平衡树
    前端网页的懒加载
    多种认证、授权模型的比较
    CSS变量(自定义属性)实践指南
    SCSS提取和懒加载
  • 原文地址:https://www.cnblogs.com/kedarui/p/3894936.html
Copyright © 2011-2022 走看看