Asp.net_获取GridView行号

来源:互联网 发布:js向json对象添加元素 编辑:程序博客网 时间:2024/05/01 20:57

在第一个GridView的SelectedIndexChanging事件中,代码

//获取选择行的编号string deptID=GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();//数据连接string sqlStr="select * from tb_Student where ID="+deptID+"";SqlConnection con=new SqlConnection();con.ConnectionString="server=Donet\\Donet2005;Database=db_09;User ID=sa;pwd=";SqlDataAdapter da=new SqlDataAdapter(sqlStr,con);DataSet ds=new DataSet();da.Fill(ds);//指定数据源this.GridView2.DataSource=ds;//绑定数据GridView2.DataBind();
原创粉丝点击