using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _11_4 : System.Web.UI.Page { public SqlConnection GetConnection() { string myStr = ConfigurationManager.AppSettings["ConnectionString"].ToString(); SqlConnection myConn = new SqlConnection(myStr); return myConn; } protected void Page_Load(object sender, EventArgs e) {
}
protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e) { //获取选择行的编号 string deptID = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString(); string strsql = "SELECT * FROM tb_Student WHERE ID='" + deptID + "'"; SqlConnection con = GetConnection(); con.Open(); SqlDataAdapter sda = new SqlDataAdapter(strsql, con); DataSet ds = new DataSet(); sda.Fill(ds); this.GridView2.DataSource = ds; this.GridView2.DataBind(); } }