我的数据网格已绑定到SQL Server数据库。数据网格显示每个房间的信息。我在asp.net的末尾添加了一个列,其中说明了详细信息。用户单击所需房间旁边的详细信息,它将打开该房间的新网页。但是可能会有一个问题,当用户寻找一个房间时,他们会做一个搜索,我如何才能做到这样,每次细节链接都链接到某个房间。
我现在想我需要在这个sql数据库房间表中添加一个新列来保存一个链接?有没有可能有人能解决这个问题。

最佳答案

ASPX页面:

<asp:Label ID="lblRoomName" runat="server"></asp:Label>

代码隐藏:
string strRoomId = Request.QueryString["Id"].ToString();
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.ConnectionStrings["dbconstr"].ConnectionString);
SqlCommand sqlcommand = new SqlCommand("Select * from RoomDetails where RoomId = @RoomId", sqlCon);
sqlcommand.Parameters.AddWithValue("@RoomId", strRoomId);
SqlDataAdapter da = new SqlDataAdapter(sqlcommand);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

10-08 14:54