搜索

View Code
1 <div>
2 <asp:TextBox ID="SearchName" class="search_bg" runat="server"></asp:TextBox>
3 <asp:Button ID="Search" runat="server" class="btn_bg" OnClick="Search_Click" />
4 </div>
5 <asp:Label ID="tx" runat="server" Visible="false" class="b_text" Text="没有查到这个结果"></asp:Label>
6 <asp:Repeater ID="MainRepeater" runat="server">
7 <ItemTemplate>
8 <div class="pro_list">
9 <div class="pro_img">
10 <img src="../client/2011/02/22/20110222134109067.jpg" alt="Products" width="144"
11 height="140" /></div>
12 <div class="pro_info">
13 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="info_1">
14 <tr>
15 <th>
16 Product ID
17 </th>
18 <td>
19 <%# Eval("productname")%>
20 </td>
21 </tr>
22 </table>
23 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="info_2">
24 <tr>
25 <th>
26 Product<br />
27 Range
28 </th>
29 <td>
30 </td>
31 <th>
32 Product<br />
33 Color
34 </th>
35 <td>
36 </td>
37 </tr>
38 <tr>
39 <th>
40 Laidprice<br />
41 /LM
42 </th>
43 <td>
44 </td>
45 <th>
46 Laidprice<br />
47 /SQM
48 </th>
49 <td>
50 </td>
51 </tr>
52 <tr>
53 <th>
54 Fiber
55 </th>
56 <td>
57 </td>
58 <th>
59 Carpet<br />
60 Style
61 </th>
62 <td>
63 </td>
64 </tr>
65 <tr>
66 <th>
67 Purpose
68 </th>
69 <td colspan="3">
70 </td>
71 </tr>
72 </table>
73 </div>
74 <p class="detals">
75 <a href="../product/20110222134117.html">
76 <img src="../images/details_btn.gif" alt="Details &amp; Quoting" width="138" height="18" /></a></p>
77 </div>
78 </ItemTemplate>
79 </asp:Repeater>
80 <div class="page">
81 <div class="page_l">
82 Total <span class="yf">
83 <asp:Label ID="TotalItem" runat="server"></asp:Label>
84 </span>pages <span class="yf">
85 <asp:DropDownList ID="PageSize" AutoPostBack="true" runat="server" OnSelectedIndexChanged="Page_Changed">
86 </asp:DropDownList>
Cs Code
1 using System;
2 using System.IO;
3 using System.Data;
4 using System.Web.UI;
5 using System.Web.UI.WebControls;
6 using System.Collections.Generic;
7 using System.Threading;
8 using System.Text;
9
10 using SigilSoft.Data.SqlClient;
11
12 using Sigil.Common;
13 using Sigil.Template;
14
15 namespace Sigil.Ste37
16 {
17
18 public partial class ProductList : PageList
19 {
20 // private static readonly string SortString = "productName";
21
22 //声明控件
23 protected TextBox SearchName = new TextBox();
24 protected DropDownList Dlb = new DropDownList();
25 protected Label tx = new Label();
26
27
28 protected void Page_Load(object sender, EventArgs e)
29 {
30 if (!IsPostBack)
31 {
32 if (SearchName.Text == null)
33 Paging(BuildInfo(), true);
34 else
35 Paging(GetInfo(), true);
36 //绑定DropList
37 //ListHelper.Bind(Dlb, DropListBrand(), "brandname", "brandid");
38 }
39 }
40 #region 获取数据
41 // 搜索
42 protected void Search_Click(object sender, EventArgs e)
43 {
44 Paging(GetInfo(), true);
45 }
46
47 //排序
48 protected void Sort_Changed(object sender, CommandEventArgs e)
49 {
50 Paging(GetInfo(), e, false);
51 }
52
53 //翻页
54 protected void Page_Changed(object sender, EventArgs e)
55 {
56 Paging(GetInfo(), true);
57 }
58
59 // 读取产品数据
60 private DataTable GetInfo()
61 {
62 DataTable dt = new DataTable();
63 string sql = "select productname, productcode from product where productname like '%{0}%' ";
64 sql = string.Format(sql, SearchName.Text);
65 Trace.Warn(sql);
66 dt = new Gladiator().GetDataTable(sql, SqlStringFrom.Program);
67 if (dt.Rows.Count > 0)
68 {
69 tx.Visible = false;
70 }
71 else
72 {
73 tx.Visible = true;
74 }
75 return dt;
76 }
77 private DataTable BuildInfo()
78 {
79 DataTable dt = new DataTable();
80
81 string sql = "select productname, productcode from product";
82 Trace.Warn(sql);
83 dt = new Gladiator().GetDataTable(sql, SqlStringFrom.Program);
84 return dt;
85 }
86 //读取DropList控件
87 private DataTable DropListBrand()
88 {
89 DataTable dt = new DataTable();
90 string sql = "selcet brandId,brandname from brand";
91 Trace.Warn(sql);
92 dt = new Gladiator().GetDataTable(sql, SqlStringFrom.Program);
93 return dt;
94 }
95 # endregion
96 }
97 }
PS : 先粘上 以后整理
posted @ 2011-03-24 16:41  Ryo  阅读(103)  评论(0编辑  收藏  举报