在DataGrid中查询单行记录并显示的问题。
在DataGrid1中添加一个LinkButton的选择列,通过点击“选择”链接把详细记录显示在DataGrid2中。我写了代码,但是当点击“选择”后2个DataGrid控件都消失不见了,请问这个功能应该如何实现。
我的代码:
private void DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string key = DataGrid1.SelectedItem.Cells[1].Text;
string sql = "SELECT ProductName, ProductVersion, ErrorCode, Description, Method, status,id FROM tblQuestion WHERE id='"+key+"'";
SqlDataAdapter sqlCommand1 = new SqlDataAdapter(sql,sqlConnection1);
sqlCommand1.Fill(dsDescription1,"tblQuestion");
DataGrid2.DataBind();
}
问题点数:40、回复次数:1Top
1 楼xyh2002(凌)回复于 2006-11-03 17:35:23 得分 0
试试使用GridView配合DetailListTop




