首页 > 学院 > 开发设计 > 正文

C#后端得到前台GridView的每行的主键值ID

2019-11-11 05:03:58
字体:
来源:转载
供稿:网友
  #region 得到前台的ID        public string getId()        {            string str_id = null;            int rowCount = post_gv.Rows.Count;  //获取前台gridview行数            for (int i = 0; i < rowCount; i++)                           //每一行进行循环遍历,如果勾选则得到ID,否则不获取            {                CheckBox check = (CheckBox)post_gv.Rows[i].FindControl("selOne");                if (check.Checked == true)                {                    int id = 0;

                    id = Convert.ToInt32(post_gv.DataKeys[i].Value);         //循环遍历ID后放在字符串里,用逗号分隔,方便拆分用户,这里注意,拆分时忽略第一个值,因为此格式为 :

                                                                                                                   //,12,30,50

                    str_id += "," + id;                }            }            return str_id;        }        #endregion
上一篇:ActiveMQ笔记(5):JMX监控

下一篇:poj 1661

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表