<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html>
<head>
<title>DataGrid HyperLinkColumn Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server" src="fetchData_sql.cs" />
<script language="C#" runat="server">
void Page_Load ( Object src, EventArgs e ) {
if ( !IsPostBack ) {
string query = "SELECT * FROM Titles";
myGrid.DataSource = fetchData ( query );
myGrid.DataBind ( );
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc" -->
<div class="header"><h2>DataGrid HyperLinkColumn Example</h2></div>
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<asp:datagrid id="myGrid" runat="server"
width="92%" cellpadding=5 font-size="9pt"
autogeneratecolumns=false
headerstyle-backcolor="maroon"
headerstyle-forecolor="khaki"
headerstyle-font-bold
itemstyle-verticalalign="top">
<columns>
<asp:hyperlinkcolumn headertext="Title"
datatextfield="title"
datanavigateurlformatstring="details_title.aspx?titleid={0}"
datanavigateurlfield="title_id" />
<asp:boundcolumn headertext="Title ID"
datafield="title_id" />
<asp:boundcolumn headertext="Category"
datafield="type" />
<asp:boundcolumn headertext="Pub ID"
datafield="pub_id" />
<asp:boundcolumn headertext="Price"
datafield="price"
dataformatstring="{0:c}"
itemstyle-horizontalalign="right" />
</columns>
</asp:datagrid>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>