<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show QueryStringParameter Master</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView
id="grdProducts"
DataSourceId="srcProducts"
AutoGenerateColumns="false"
ShowHeader="false"
Runat="server">
<Columns>
<asp:HyperLinkField
DataTextField="Title"
DataNavigateUrlFields="Id"
DataNavigateUrlFormatString="ShowQueryStringParameterDetails.aspx?id={0}" />
</Columns>
</asp:GridView>
<asp:SqlDataSource
id="srcProducts"
SelectCommand="SELECT * FROM Products"
ConnectionString="<%$ ConnectionStrings:Products %>"
Runat="server" />
</div>
</form>
</body>
</html>
File: ShowQueryStringParameterDetails.aspx
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show QueryStringParameter Details</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DetailsView
id="dtlProduct"
DataSourceID="srcProduct"
Runat="server" />
<asp:SqlDataSource
id="srcProduct"
SelectCommand="SELECT * FROM Products
WHERE Id=@Id"
ConnectionString="<%$ ConnectionStrings:Products %>"
Runat="server">
<SelectParameters>
<asp:QueryStringParameter
Name="Id"
QueryStringField="Id" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
File: Web.config
<configuration>
<connectionStrings>
<add name="Products"
connectionString="Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|MyDatabase.mdf;Integrated Security=True;User Instance=True" />
</connectionStrings>
</configuration>
|