string newsid =?
唉,不行啊,我换了一种方法,能不能帮我看看啊
页面左侧是一个GRIDVIEW,只显示了标题字段,我想点击其中一行后,在右边的4个TEXTBOX里显示数据表中的其他内容
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
string conn = ConfigurationSettings.AppSettings["strConn"].ToString();
SqlConnection con = new SqlConnection(conn);
con.Open();
SqlDataAdapter myCommand = new SqlDataAdapter("newsList", con);
DataSet myDataSet = new DataSet();
//填充DataSet
myCommand.Fill(myDataSet);
//关闭链接
GridView1.DataSource = myDataSet;
//绑定
GridView1.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
this.TextBox1.Text = this.GridView1.SelectedDataKey["biaoti"].ToString();
this.TextBox2.Text = this.GridView1.SelectedDataKey["fabuzhe"].ToString();
this.TextBox3.Text = this.GridView1.SelectedDataKey["shijian"].ToString();
this.TextBox4.Text = this.GridView1.SelectedDataKey["neirong"].ToString();
}
}
可是点击没反映