我在 asp.net 中的数据网格视图仅将 sql server 数据库中的选定 ID 显示为单行。
现在我需要在单击特定 id(数据行)时显示特定页面,并且我想在属于所选 id 的新页面中显示所有详细信息(单击 id)。
我试过这段代码:
protected void btnserch_Click(object sender, EventArgs e)
{
SqlConnection objsqlconnection = new SqlConnection(CONNECTIONSTRING);
string query = "Select id from registration";
SqlCommand objsqlcommand = new SqlCommand(query, objsqlconnection);
objsqlconnection.Open();
SqlDataAdapter da=new SqlDataAdapter();
DataSet ds=new DataSet();
objsqlcommand.CommandText = query;
objsqlcommand.Connection = objsqlconnection;
da = new SqlDataAdapter(objsqlcommand);
da.Fill(ds);
objsqlcommand.ExecuteNonQuery();
GridView1.DataSource = ds;
GridView1.DataBind();
objsqlconnection.Close();
}
此代码通过从注册表中仅选择 id 列来返回一个网格。现在,当我单击 id 列的数据行时,我需要另一个页面来显示属于该 id 的所有详细信息。