2013. 3. 9. 09:37
출처: http://mimor.be/2011/asp-net-gridview-to-display-detailsview-on-other-page/
다른 페이지에서 사용하기
Double click the GridView item in your GUI.
You’ll get something as:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged End Sub
Now add the following code (note that this is in vb, so if you use C#, adjust the syntax)
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Response.Redirect("DetailsView.aspx?ID=" & GridView1.SelectedValue)
End Sub
You might also want to add or modify some lines in your sqlDatasource (of the destination page) to match these lines.
This way you’ll see the DetailView of the item you clicked in the GridView.
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="SELECT * FROM [Tablename]where [ID] = @ID"
<SelectParameters>
<asp:QueryStringParameter QueryStringField="ID" name="ID" />
</SelectParameters>
</asp:SqlDataSource>