源代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Search.aspx.cs" Inherits="WebApplication1.Search" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace ="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>.NET</title>
<meta http-equiv="Content-Type" content="text/html" />
<script language="C#" runat="server">
void btnSearch_Click(Object sender, EventArgs E)
{
SqlConnection sConn = new SqlConnection((String)ConfigurationManager.AppSettings["connString"]);
string queryStr = "select book_id,title,price,type from books where title like '%" + TextBox1.Text + "%'";
SqlDataAdapter resAdapter = new SqlDataAdapter(queryStr, sConn);
DataSet resSet = new DataSet();
resAdapter.Fill(resSet, "books");
bookGrid.DataSource = resSet.Tables["books"].DefaultView;
bookGrid.DataBind();
}
</script>
</head>
<body bgcolor="#ffccff" link="ffff00" vlink="#ffff00" alink="00ff00">
<h1>查询结果如下:</h1>
<form id="form1" runat="server">
查询:<asp:TextBox ID="TextBox1" text="" MaxLength ="50" runat="server"/>
<br />
<asp:Button ID ="btnSearch" Text ="查询!" OnClick ="btnSearch_Click" runat ="server" />
<asp:DataGrid ID ="bookGrid" runat ="server"
BorderColor="Black"
BorderWidth="2px"
Font-Name="Tohoma"
HeaderStyle-BackColor="Gray"
AutoGenerateColumms="false" Font-Names="Tohoma">
<Columns >
<asp:HyperLinkColumn
HeaderText="书名"
DataNavigateUrlField="book_id"
DataNavigateUrlFormatString ="ShowDetail.aspx?book_id={0}"
DataTextField="title" />
<asp:BoundColumn HeaderText ="类别" DataField ="type" />
<asp:BoundColumn HeaderText ="价格"
DataField ="price"
DataFormatString ="{0:c}"
ItemStyle-HorizontalAlign="right" />
</Columns>
</asp:DataGrid>
</form>
</body>
</html>
付费偷看金额在0.1-10元之间
这是很常见的网页错误,建议用多种不同内核浏览器试试。
一周热门 更多>