• GridView中数据行的操作


    一个是直接动态绑定gridview 用3楼的办法就可以了
    int j=1;//j的数值表示你要取的那一列的索引,要取第二列,j就设为1
    for (int i = 0; i < this.GridView1.Rows.Count; i++)
    {
    str[i]= this.GridView1.Rows[i].Cells[j].Text;//str[i]就存放了gridview1中第i行第2列的值
    }
    二个是模板化的gridview (模板化的可以改变列的位置,控制列的隐藏显示,以及编辑等功能) 就要用
    TextBox Tb=(TextBox)GridView1.Rows[i].Cell[1].FindControl("TextBox1");
    string str=tb.text.tostring() 的方法获取值,如果是Label,DropDownlist 换过来就是了。因为用模板的时候.GridView1.Rows[i].Cells[j].Text 这样的语句是取不到值的

    为GridView绑定数据的时候可以设制多个参数列以便在处理数据时用到作为条件增删改查如下:

     DataSet ds = bll.GetAll(AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1), AspNetPager1.PageSize, out count, Request.QueryString["LendNum"].ToString());
                AspNetPager1.RecordCount = count;
                HT_LoanInformationGrid.DataSource = ds.Tables[0].DefaultView;
                HT_LoanInformationGrid.DataKeyNames = new string[] { "MortgageDetail" ,"Params2"};
                HT_LoanInformationGrid.DataBind();
    到用时就用

     string loanerId = HT_LoanInformationGrid.DataKeys[0].Value.ToString();
     string loanerId = HT_LoanInformationGrid.DataKeys[1].Value.ToString();
  • 相关阅读:
    Java面向对象XMind
    使用idea插件JRebel热部署的坑
    Mysql小技巧(多行数据合并+模糊查询
    JRebel安装使用
    Shiro(三) 权限管理 假数据
    Shiro(二)通过shiro实现登录 连接数据库+集成Springboot
    Shiro(一)通过shiro实现登录
    poi实现Excel输出
    日志,注解切入点
    获取用户信息
  • 原文地址:https://www.cnblogs.com/haofaner/p/3664382.html
Copyright © 2020-2023  润新知