供求信息网

 

后台数据库由四个表组成,tb_info供求信息表,tb_LeaguerInfo收费供求信息表,tb_Power网站后台用户表,tb_PowerLog后台用户登录日志

checkState bit  默认为((0)),date datetime 默认为(getdate())

公共类设计 组织封装一些常用的方法和事件,放在App_Code文件夹

数据层功能设计DataBase.cs,逻辑业务功能设计Operation.cs

以上两个操作略去,可参考源头代码。

里面有这个可以看看

 #region  分页设置绑定
    /// <summary>
    /// 绑定DataList控件,并且设置分页
    /// </summary>
    /// <param name="infoType">信息类型</param>
    /// <param name="infoKey">查询的关键字(如果为空,则查询所有)</param>
    /// <param name="currentPage">当前页</param>
    /// <param name="PageSize">每页显示数量</param>
    /// <returns>返回PagedDataSource对象</returns>
    public PagedDataSource PageDataListBind(string infoType, string infoKey, int currentPage,int PageSize)
    {
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = SelectInfo(infoType, infoKey).Tables[0].DefaultView; //将查询结果绑定到分页数据源上。
        pds.AllowPaging = true;          //允许分页
        pds.PageSize = PageSize;          //设置每页显示的页数
        pds.CurrentPageIndex = currentPage - 1;   //设置当前页
        return pds;
    }
    #endregion

 

网站主页设计

 使用了母板页技术,母板页是一个MasterPage类,继承自UserControl

三个级别配置,一般是页面级别,也可在应用程序级(全都用这个了),

<system.web>

<pages master="??.master">

</system.web>

文件夹级,和上面类似,不过是写在一个文件夹的web.config中啦,哈哈

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<html>
<head runat="server">
    <title>无标题页</title>
    <link href="css/css.css" rel="stylesheet" type="text/css" />
</head>
<%--oncontextmenu=window.event.returnValue=false onselectstart=window.event.returnValue=false ondragstart=window.event.returnValue=false--%>
<body>
    <form id="form1" runat="server">
        <table cellpadding="0" cellspacing="0" style="width: 1003px">
            <tr>
                <td style="width: 112px; height: 23px;">
                </td>
                <td style="width: 778px; height: 23px;">
                    <table align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" width="778">
                        <tr>
                            <td align="left" width="546">
                                <img height="36" src="images/01.GIF" width="248" /></td>
                            <td class="shenhong" valign="bottom" width="232">
                                <span style="font-size: 12px">


                                <a href="javascript:window.external.addFavorite('http://www.mingrisoft.com/about.asp','**科技有限公司');">加入收藏 </a>                       

&nbsp; |&nbsp;

<a href=# onClick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.cxyhome.com');">设为首页</a>


</span>&nbsp; |&nbsp;

<a href="mailto:ABC***@1**.COM">联系我们</a></td>
                        </tr>
                    </table>
                    <table align="center" background="images/daohangb.GIF" bgcolor="#ffffff" cellpadding="0"
                        cellspacing="0" height="55" width="778">
                        <tr>
                            <td valign="top">
                                <table cellpadding="0" cellspacing="0" height="27" width="779">
                                    <tr>
                                        <td class="daohangh" style="width: 153px">
                                            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                            <asp:HyperLink ID="HyperLink1" runat="server" CssClass="daohangh" NavigateUrl="~/Default.aspx">首  页</asp:HyperLink></td>
                                        <td align="center" class="daohangh" style="width: 110px">
                                            <a href="ShowPage/webZP.aspx"></a>
                                            <asp:HyperLink ID="HyperLink2" runat="server" CssClass="daohangh" NavigateUrl="~/ShowPage/webZP.aspx">招聘信息</asp:HyperLink></td>
                                        <td align="center" class="daohangh" width="117">
                                            <a href="ShowPage/webGY.aspx"></a>
                                            <asp:HyperLink ID="HyperLink3" runat="server" CssClass="daohangh" NavigateUrl="~/ShowPage/webGY.aspx">公寓信息</asp:HyperLink></td>
                                        <td align="center" class="daohangh" width="112">
                                            <a href="ShowPage/webWPQG.aspx"></a>
                                            <asp:HyperLink ID="HyperLink4" runat="server" CssClass="daohangh" NavigateUrl="~/ShowPage/webWPQG.aspx">物品求购</asp:HyperLink></td>
                                        <td align="center" class="daohangh" width="116">
                                            <a href="ShowPage/webQDCD.aspx"></a>
                                            <asp:HyperLink ID="HyperLink5" runat="server" CssClass="daohangh" NavigateUrl="~/ShowPage/webQDCD.aspx">求兑出兑</asp:HyperLink></td>
                                        <td width="169">
                                            &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span class="daohangh"><asp:HyperLink ID="HyperLink6" runat="server" CssClass="daohangh" NavigateUrl="~/ShowPage/webXQHZ.aspx">寻求合作</asp:HyperLink></span></td>
                                    </tr>
                                </table>
                                <table cellpadding="0" cellspacing="0" class="shenlan" height="28" width="779">
                                    <tr>
                                        <td class="shenlan" width="153">
                                            &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="shenlan"><asp:HyperLink ID="HyperLink7" runat="server" CssClass="shenlan" NavigateUrl="~/ShowPage/webPX.aspx">培训信息</asp:HyperLink></span></td>
                                        <td align="center" class="shenlan" width="110">
                                            <a href="ShowPage/webQZ.aspx"></a>
                                            <asp:HyperLink ID="HyperLink8" runat="server" CssClass="shenlan" NavigateUrl="~/ShowPage/webQZ.aspx">求职信息</asp:HyperLink></td>
                                        <td align="center" class="shenlan" width="117">
                                            <a href="ShowPage/webJJ.aspx"></a>
                                            <asp:HyperLink ID="HyperLink9" runat="server" CssClass="shenlan" NavigateUrl="~/ShowPage/webJJ.aspx">家教信息</asp:HyperLink></td>
                                        <td align="center" class="shenlan" width="112">
                                            <a href="ShowPage/webWPCS.aspx"></a>
                                            <asp:HyperLink ID="HyperLink10" runat="server" CssClass="shenlan" NavigateUrl="~/ShowPage/webWPCS.aspx">物品出售</asp:HyperLink></td>
                                        <td align="center" class="shenlan" width="116">
                                            <a href="ShowPage/webCL.aspx"></a>
                                            <asp:HyperLink ID="HyperLink11" runat="server" CssClass="shenlan" NavigateUrl="~/ShowPage/webCL.aspx">车辆信息</asp:HyperLink></td>
                                        <td class="shenlan" width="169">
                                            &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;
                                            <asp:HyperLink ID="HyperLink12" runat="server" CssClass="shenlan" NavigateUrl="~/ShowPage/webQYGG.aspx">企业广告</asp:HyperLink></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" height="112"
                        width="778">
                        <tr>
                            <td align="left" background="images/banner.jpg" height="112">
                            </td>
                        </tr>
                    </table>
           
                </td>
                <td style="width: 112px; height: 23px;">
                </td>
            </tr>
            <tr>
                <td style="width: 112px; height: 208px;">
                </td>
                <td style="width: 778px; height: 208px;">
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                        </asp:ContentPlaceHolder>
                </td>
                <td style="width: 112px; height: 208px;">
                </td>
            </tr>
            <tr>
                <td style="width: 112px; height: 29px;">
                </td>
                <td style="width: 778px; height: 29px;">
                    <table align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" height="59"
                        width="778">
                        <tr>
                            <td background="images/end.gif" height="59" valign="bottom">
                                <table align="center" width="359">
                                    <tr>
                                        <td align="center" class="danhuang" valign="bottom" width="363">
                                            公司网址:www.mingri**ft.com 联系电:87****1287&nbsp; 96454**13<br />
                                            吉林省**科技有限公司 版权所有 &nbsp;&nbsp;<a href="../Logon.aspx"><span class="danhuang" style=" text-decoration:none">后台入口</span></a></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: 112px; height: 29px;">
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

一个可以在首页左边跑的发布图片链接
<script language="JavaScript1.2">
function move(x) {
if (document.all) {
object1.style.pixelLeft += x;
object1.style.visibility = "visible"}
else if (document.layers) {
document.object1.left += x;
document.object1.visibility = "show"}};
function makeStatic() {
if (document.all) {object1.style.pixelTop=document.body.scrollTop+20}
else {eval(document.object1.top=eval(window.pageYOffset+20));}
setTimeout("makeStatic()",0);}
</script>


<script language="JavaScript1.2">
function positionmenu(){
move(-100)
}
if (document.all) {document.write('<DIV ID="object1" style="visibility:hidden;cursor:hand; Position : Absolute ;Left : 100px ;Top : 120px ;100 : 120">')}
</script>
<table border="0" cellpadding="0" cellspacing="0" width="115" bgcolor="#000000">
<script language="JavaScript1.2"><!--
if (document.all||document.layers) {
makeStatic();}
var text=new Array();
var thelink=new Array();
text[0]="";
thelink[0]="../infoadd.aspx";
var linktarget=''
function navigateie(which){
if (linktarget=='')
window.location=thelink[which]
else if (linktarget=='new')
window.open(thelink[which])
else{
temp_var=eval("window.parent."+linktarget)
temp_var.location=thelink[which]
}
}
for (i=0;i<=text.length-1;i++)
if (document.all) {document.write('<TR><TD height=159 background=images/fabu.gif onclick="navigateie('+i+')" onmouseover="className=\'hl\'" onmouseout="className=\'n\'"><FONT SIZE=2 FACE=ARIAL>&nbsp;'+text[i]+'</FONT></TD></TR>')}
else {document.write('<TR><TD background="images/fabu.gif"><ILAYER><LAYER HEIGHT="18" width=131><FONT SIZE=2 FACE=ARIAL>&nbsp;<A HREF="'+thelink[i]+'" target="'+linktarget+'" id="nounderline">'+text[i]+'</A></FONT></LAYER></ILAYER></TD></TR>')}
</script>
<tr>
<td bgcolor="#0099FF"><font size="1" face="Arial"> </font></td>
</TR>
</table>
<script language="JavaScript1.2">
if (document.all) {document.write('</DIV>')}
window.onload=positionmenu
</script>

 

 

主页的实现

用6个datalist数据控件

俩个用户控件,一个推荐,一个搜索

<%@ Register Src="UserControl/RecommendInfo.ascx" TagName="RecommendInfo" TagPrefix="uc1" %>
<%@ Register Src="UserControl/InfoSearch.ascx" TagName="InfoSearch" TagPrefix="uc2" %>

<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">
    <table align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" height="400"
        width="778">
        <tr>
            <td background="images/beijing.gif" valign="top">
                <table cellpadding="0" cellspacing="0" width="778">
                    <tr>
                        <td align="center" valign="top" width="216">
                            <table cellpadding="0" cellspacing="0" width="59">
                                <tr>
                                    <td valign="top">
                                        <img height="28" src="images/left1.GIF" width="213" /></td>
                                </tr>
                                <tr>
                                    <td align="center" bgcolor="#fffef6" height="166" valign="middle">
                                        <uc1:RecommendInfo ID="RecommendInfo1" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <img height="30" src="images/left2.gif" width="213" /></td>
                                </tr>
                                <tr>
                                    <td background="images/xiaobei.gif" height="105">
                                        <uc2:InfoSearch ID="InfoSearch1" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <img height="29" src="images/left3.gif" width="214" /></td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <table cellpadding="0" cellspacing="0" height="149" width="194">
                                            <tr>
                                                <td align="left" class="huise1" width="194">
                                                    <span class="hongcu">吉林省***科技有限公司</span><br />
                                                    <table bgcolor="#cc0000" cellpadding="0" cellspacing="0" height="3" width="194">
                                                        <tr>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    <br />
                                                    联系地址:****市东*大街亚****广<br />
                                                    场座2205室<br />
                                                    联系电话:885**86 88**4275<br />
                                                    邮政编码:1**000</td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td align="right" valign="top" width="560">
                            <table cellpadding="0" cellspacing="0" width="10">
                                <tr>
                                    <td colspan="2">
                                        <img border="0" height="28" src="images/right1.gif" usemap="#Map" width="561" />
                                        <map id="Map" name="Map">
                                            <area coords="223,4,265,21" href="ShowPage/webZP.aspx" shape="RECT" />
                                            <area coords="508,5,550,22" href="ShowPage/webPX.aspx" shape="RECT" />
                                        </map>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="left" style="height: 120px" valign="top" width="285">
                                        <asp:DataList ID="dlZP" runat="server" CssClass="hong">
                                            <ItemTemplate>
                                                <table align="center" cellpadding="0" cellspacing="0" width="266">
                                                    <tr>
                                                        <td>
                                                            <span class="hong" style="color: #000000">·<a class="huise" href="#"
             onClick="window.open('ShowLeaguerInfo.aspx?id=<%#DataBinder.Eval(Container.DataItem,"id") %>','','height=258, width=479, top=200, left=200')"><%#DataBinder.Eval(Container.DataItem,"title") %></a></span>
</td>
                                                    </tr>
                                                    <tr style="color: #000000">
                                                        <td>
                                                            <img height="1" src="images/line.gif" width="266" /></td>
                                                    </tr>
                                                </table>
                                  

          </ItemTemplate>
                                        </asp:DataList></td>

其它五个,基本一样
                                

</asp:Content>

实现代码

public partial class _Default : System.Web.UI.Page
{
    Operation operation = new Operation();  //声明网站业务类对象
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)  //!IsPostBack避免重复刷新加载页面
        {
            //获取前6条分类供求信息
            dlZP.DataSource = operation.SelectLeaguerInfo(true, "招聘信息", 6);
            dlZP.DataBind();
            dlPX.DataSource = operation.SelectLeaguerInfo(true, "培训信息", 6);
            dlPX.DataBind();
            dlGY.DataSource = operation.SelectLeaguerInfo(true, "公寓信息", 6);
            dlGY.DataBind();
            dlJJ.DataSource = operation.SelectLeaguerInfo(true, "家教信息", 6);
            dlJJ.DataBind();
            dlWPQG.DataSource = operation.SelectLeaguerInfo(true, "物品求购", 6);
            dlWPQG.DataBind();
            dlWPCS.DataSource = operation.SelectLeaguerInfo(true, "物品出售", 6);
            dlWPCS.DataBind();
            dlQDCD.DataSource = operation.SelectLeaguerInfo(true, "求兑出兑", 6);
            dlQDCD.DataBind();
            dlCL.DataSource = operation.SelectLeaguerInfo(true, "车辆信息", 6);
            dlCL.DataBind();
        }
    }
}

招聘信息页,分为上下两部分,上收费,下免费

是用datalist,它一个好处是可以自定义布局呀,但分页需要pagedatasource类配合支持

http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.datalist(VS.80).aspx

 

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="webCL.aspx.cs" Inherits="ShowPage_webCL" Title="供求信息---车辆信息" %>

<%@ Register Src="../UserControl/RecommendInfo.ascx" TagName="RecommendInfo" TagPrefix="uc2" %>

<%@ Register Src="../UserControl/InfoSearch.ascx" TagName="InfoSearch" TagPrefix="uc1" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table cellpadding="0" cellspacing="0" width="778" bgcolor="#ffffff" background="images/beijing.gif">
        <tr>
            <td align="center" valign="top" width="216" style="height: 1016px">
                <table cellpadding="0" cellspacing="0" width="59">
                    <tr>
                        <td valign="top">
                            <img height="28" src="images/left1.GIF" width="213" /></td>
                    </tr>
                    <tr>
                        <td align="center" bgcolor="#fffef6" height="166" valign="middle">
                            <uc2:RecommendInfo ID="RecommendInfo1" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <img height="30" src="images/left2.gif" width="213" /></td>
                    </tr>
                    <tr>
                        <td background="images/xiaobei.gif" height="105">
                            <uc1:InfoSearch ID="InfoSearch1" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <img height="29" src="images/left3.gif" width="214" /></td>
                    </tr>
                    <tr>
                        <td align="center">
                            <table cellpadding="0" cellspacing="0" height="149" width="194">
                                <tr>
                                    <td align="left" class="huise" width="194">
                                        <span style="color: #000000"><span class="hongcu">吉林省***科技有限公司</span><br />
                                        </span>
                                        <table bgcolor="#cc0000" cellpadding="0" cellspacing="0" height="3" style="color: #000000"
                                            width="194">
                                            <tr>
                                                <td>
                                                </td>
                                            </tr>
                                        </table>
                                        <br />
                                        <span class="banhui"><span style="color: #000000">联系地址:****市东*大街亚****广<br />
                                        </span><span style="color: #000000">场座2205室<br />
                                        </span><span style="color: #000000">联系电话:885**86 88**4275<br />
                                        </span><span style="color: #000000">邮政编码:1**000</span></span></td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
            <td align="center" style="color: #000000; width: 560px; height: 1016px;" valign="top" class="txt">
                <table cellpadding="0" cellspacing="0" width="10">
                    <tr>
                        <td>
                            <img border="0" height="28" src="images/right5.gif" width="561" /></td>
                    </tr>
                    <tr>
                        <td align="left" height="20" valign="top" bgcolor="#ffffff">


                            <asp:DataList ID="dlCharge" runat="server" Width="543px">
                                <ItemTemplate>
                                    <table align="center" cellpadding="0" cellspacing="0" width="543">
                                        <tr>
                                            <td>
                                                <span class="hongcu">『<%# DataBinder.Eval(Container.DataItem,"type") %>』</span><span class="chengse"><%# DataBinder.Eval(Container.DataItem,"title") %></span>
                                                <span class="huise1">
                                                    <%#DataBinder.Eval(Container.DataItem,"date") %>
                                                </span>
                                                <br />
                                                <span class="shenlan">
                                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%#DataBinder.Eval(Container.DataItem,"info") %>
                                                </span>
                                                <br />
                                                <span class="chengse">联系人:<%#DataBinder.Eval(Container.DataItem,"linkMan") %>
                                                    联系电话:<%#DataBinder.Eval(Container.DataItem,"tel") %></span></td>
                                        </tr>
                                        <tr style="color: #000000">
                                            <td align="center">
                                                <img height="1" src="images/longline.gif" width="525" /></td>
                                        </tr>
                                        <tr style="color: #000000">
                                            <td height="10">
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </asp:DataList></td>
                    </tr>
                    <tr style="color: #000000">
                        <td height="0">
                        </td>
                    </tr>
                </table>
                <table cellpadding="0" cellspacing="0" style="color: #000000" width="10">
                    <tr>
                        <td height="75" valign="top">
                            <img height="67" src="images/banner1.jpg" width="559" /></td>
                    </tr>
                </table>
                <table cellpadding="0" cellspacing="0" style="color: #000000" width="10">
                    <tr>
                        <td style="width: 581px">
                            <img border="0" height="28" src="images/right6.gif" width="561" /></td>
                    </tr>
                    <tr>
                        <td align="left" height="20" valign="top" style="width: 581px">
                            <asp:DataList ID="dlFree" runat="server">
                                <ItemTemplate>
                                    <table align="center" cellpadding="0" cellspacing="0" width="543">
                                        <tr>
                                            <td class="huise">
                                                <span class="shenlancu">『<%# DataBinder.Eval(Container.DataItem,"type") %>』</span><span
                                                    class="banhui"><%# DataBinder.Eval(Container.DataItem,"title") %>[
                                                        <%# DataBinder.Eval(Container.DataItem,"date") %>
                                                        ]
                                                        <br />
                                                    </span><span class="banhui">
                                                       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%# DataBinder.Eval(Container.DataItem,"info") %>
                                                        <br />
                                                    </span><span class="banhui">联系人:<%#DataBinder.Eval(Container.DataItem,"linkMan") %>
                                                        联系电话:<%#DataBinder.Eval(Container.DataItem,"tel") %></span></td>
                                        </tr>
                                        <tr style="color: #000000">
                                            <td align="center">
                                                <img height="1" src="images/longline.gif" width="525" /></td>
                                        </tr>
                                        <tr style="color: #000000">
                                            <td height="10">
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </asp:DataList>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 581px; height: 11px;">
                        </td>
                    </tr>
                </table>
                当前页码为[<asp:Label ID="lblCurrentPage" runat="server" Text="1"></asp:Label>]页 总页码[<asp:Label
                    ID="lblSumPage" runat="server" Text="0"></asp:Label>]页
                <asp:LinkButton ID="lnkBtnFirst" runat="server" Font-Underline="False" OnClick="lnkBtnFirst_Click"> 第一页 </asp:LinkButton>
                <asp:LinkButton ID="lnkBtnPrevious" runat="server" Font-Underline="False" OnClick="lnkBtnPrevious_Click"> 上一页 </asp:LinkButton>
                <asp:LinkButton ID="lnkBtnNext" runat="server" Font-Underline="False" OnClick="lnkBtnNext_Click"> 下一页 </asp:LinkButton>
                <asp:LinkButton ID="lnkBtnLast" runat="server" Font-Underline="False" OnClick="lnkBtnLast_Click"> 末一页 </asp:LinkButton></td>
        </tr>
    </table>
</asp:Content>

 

public partial class ShowPage_webCL : System.Web.UI.Page
{
    Operation operation = new Operation();
    static string infoType = "";
    static string infoKey = "";
    static PagedDataSource pds = new PagedDataSource();   

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            infoType = "车辆信息";
            infoKey = Convert.ToString(Session["key"]);
            this.DataListBind();

            dlCharge.DataSource = operation.SelectLeaguerInfo(true, infoType);
            dlCharge.DataBind();
            Session["key"] = null;
        }
    }
    /// <summary>
    /// 将数据绑定到DataList控件
    /// </summary>
    public void DataListBind()
    {
        pds = operation.PageDataListBind(infoType, infoKey, Convert.ToInt32(lblCurrentPage.Text), 10);
        lnkBtnFirst.Enabled = true;      //控件翻页控件都设置为可用
        lnkBtnLast.Enabled = true;
        lnkBtnNext.Enabled = true;
        lnkBtnPrevious.Enabled = true;
        if (lblCurrentPage.Text == "1")   //如果当前显示第一页,“第一页”和“上一页”按钮不可用。
        {
            lnkBtnPrevious.Enabled = false;
            lnkBtnFirst.Enabled = false;
        }
        if (lblCurrentPage.Text == pds.PageCount.ToString())  //如果显示最后一页,“末一页”和“下一页”按钮不可用。
        {
            lnkBtnNext.Enabled = false;
            lnkBtnLast.Enabled = false;
        }
        lblSumPage.Text = pds.PageCount.ToString();  //实现总页数
        dlFree.DataSource = pds;            //绑定数据源
        dlFree.DataKeyField = "id";
        dlFree.DataBind();
    }
    protected void lnkBtnFirst_Click(object sender, EventArgs e)
    {
        lblCurrentPage.Text = "1";
        DataListBind();
    }
    protected void lnkBtnPrevious_Click(object sender, EventArgs e)
    {
        lblCurrentPage.Text = (Convert.ToInt32(lblCurrentPage.Text) - 1).ToString();
        DataListBind();
    }
    protected void lnkBtnNext_Click(object sender, EventArgs e)
    {
        lblCurrentPage.Text = (Convert.ToInt32(lblCurrentPage.Text) + 1).ToString();
        DataListBind();
    }
    protected void lnkBtnLast_Click(object sender, EventArgs e)
    {
        lblCurrentPage.Text = lblSumPage.Text;
        DataListBind();
    }
}

 

免费供求信息发布页

验证控件的正则表达式"(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}"

 

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table align="center" bgcolor="#ffffff" cellpadding="0" cellspacing="0" height="400"
        width="778">
        <tr>
            <td background="images/beijing.gif" valign="top">
                <table cellpadding="0" cellspacing="0" width="778">
                    <tr>
                        <td align="center" valign="top" width="216">
                            <table cellpadding="0" cellspacing="0" width="59">
                                <tr>
                                    <td valign="top">
                                        <img height="28" src="images/left1.GIF" width="213" /></td>
                                </tr>
                                <tr>
                                    <td align="center" bgcolor="#fffef6" height="166" valign="middle">
                                        <uc2:RecommendInfo ID="RecommendInfo1" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <img height="30" src="images/left2.gif" width="213" /></td>
                                </tr>
                                <tr>
                                    <td background="images/xiaobei.gif" height="105">
                                        <uc1:InfoSearch ID="InfoSearch1" runat="server" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <img height="29" src="images/left3.gif" width="214" /></td>
                                </tr>
                                <tr>
                                    <td align="center">
                                        <table cellpadding="0" cellspacing="0" height="149" width="194" class="txt">
                                            <tr>
                                                <td align="left" class="huise" width="194" style="height: 136px">
                                                    <span class="hongcu">吉林省***科技有限公司</span><br />
                                                    <table bgcolor="#cc0000" cellpadding="0" cellspacing="0" height="3" width="194">
                                                        <tr>
                                                            <td>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                    联系地址:****市东*大街亚****广<br />
                                                    场座2205室<br />
                                                    联系电话:885**86 88**4275<br />
                                                    邮政编码:1**000</td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td align="right" valign="top" width="560">
                            <table cellpadding="0" cellspacing="0" width="10">
                                <tr>
                                    <td>
                                        <img border="0" height="28" src="images/mianfeifabu.gif" width="561" /></td>
                                </tr>
                                <tr>
                                    <td align="left" height="400" style="text-align: center" valign="middle">
                <table style="width: 520px; height: 116px" cellpadding="0" cellspacing="0" class="txt">
                    <tr>
                        <td style="width: 85px" align="right">
                            信息类别:</td>
                        <td style="width: 336px" align="left">
                            <asp:DropDownList ID="DropDownList1" runat="server" Width="121px">
                                <asp:ListItem>招聘信息</asp:ListItem>
                                <asp:ListItem>求职信息</asp:ListItem>
                                <asp:ListItem>培训信息</asp:ListItem>
                                <asp:ListItem>家教信息</asp:ListItem>
                                <asp:ListItem>公寓信息</asp:ListItem>
                                <asp:ListItem>物品求购</asp:ListItem>
                                <asp:ListItem>物品出售</asp:ListItem>
                                <asp:ListItem>求兑出兑</asp:ListItem>
                                <asp:ListItem>车辆信息</asp:ListItem>
                                <asp:ListItem>寻求合作</asp:ListItem>
                                <asp:ListItem>企业广告</asp:ListItem>
                            </asp:DropDownList></td>
                        <td style="width: 89px">
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 85px" align="right">
                            信息标题:</td>
                        <td style="width: 336px" align="left">
                            <asp:TextBox ID="txtTitle" runat="server" Width="337px"></asp:TextBox></td>
                        <td style="width: 89px">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTitle"
                                ErrorMessage="* 必填项"></asp:RequiredFieldValidator></td>
                    </tr>
                    <tr>
                        <td style="width: 85px" align="right">
                            信息内容:</td>
                        <td style="width: 336px" align="left">
                            <asp:TextBox ID="txtInfo" runat="server" Height="147px" TextMode="MultiLine" Width="360px"></asp:TextBox></td>
                        <td style="width: 89px">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtInfo"
                                ErrorMessage="* 必填项"></asp:RequiredFieldValidator></td>
                    </tr>
                    <tr>
                        <td style="width: 85px" align="right">
                            联系人:</td>
                        <td style="width: 336px" align="left">
                            <asp:TextBox ID="txtLinkMan" runat="server"></asp:TextBox></td>
                        <td style="width: 89px">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtLinkMan"
                                ErrorMessage="* 必填项"></asp:RequiredFieldValidator></td>
                    </tr>
                    <tr>
                        <td style="width: 85px; height: 24px;" align="right">
                            联系电话:</td>
                        <td style="width: 336px; height: 24px;" align="left">
                            <asp:TextBox ID="txtTel" runat="server"></asp:TextBox>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtTel"
                                ErrorMessage="格式:(3/4位)-(7/8位)" ValidationExpression="(\(\d{3,4}\)|\d{3,4}-)?\d{7,8}"></asp:RegularExpressionValidator></td>
                        <td style="width: 89px; height: 24px;">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtTel"
                                ErrorMessage="* 必填项"></asp:RequiredFieldValidator></td>
                    </tr>
                    <tr>
                        <td style="width: 85px; height: 43px">
                        </td>
                        <td style="width: 336px; height: 43px">
                        </td>
                        <td style="width: 89px; height: 43px">
                        </td>
                    </tr>
                </table>
            <asp:ImageButton ID="imgBtnAdd" runat="server" AlternateText="发布信息" Height="46px"
                    OnClick="imgBtnAdd_Click" Width="145px" ImageUrl="images/kaishifa.jpg" /></td>
                                </tr>
                                <tr>
                                    <td height="2">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>

后台

  protected void imgBtnAdd_Click(object sender, ImageClickEventArgs e)
    {
        operation.InsertInfo(DropDownList1.Text, txtTitle.Text.Trim(), txtInfo.Text.Trim(), txtLinkMan.Text.Trim(), txtTel.Text.Trim());
        WebMessageBox.Show("信息发布成功!", "Default.aspx");
    }

 

网站后台

iframe技术,treeview做导航

 <table id="__01" border="0" cellpadding="0" cellspacing="0" height="598" width="1003">
            <tr>
                <td colspan="2">
                    <img alt="" border="0" height="93" src="images/guanli_01.jpg" usemap="#Map" width="1003" /></td>
            </tr>
            <tr>
                <td>
                    <img alt="" height="33" src="images/guanli_02.jpg" width="182" /></td>
                <td background="images/guanli_03.jpg" height="33" width="821">
                    <table cellpadding="0" cellspacing="0" width="589">
                        <tr>
                            <td width="41">
                                &nbsp;</td>
                            <td class="huise" width="546">
                                现在的位置:供求信息网 &gt; <span class="hong">后台管理系统</span>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td background="images/guanli_04.jpg" colspan="2" height="420" valign="top">
                    <table cellpadding="0" cellspacing="0" width="981">
                        <tr>
                            <td width="10">
                                &nbsp;</td>
                            <td width="144">
                                &nbsp;</td>
                            <td width="55">
                                &nbsp;</td>
                            <td class="huise" width="770">
                                &nbsp;</td>
                        </tr>
                    </table>
                    <table cellpadding="0" cellspacing="0" style="width: 991px">
                        <tr>
                            <td style="width: 185px; height: 374px" align="center">
                               

 <asp:TreeView ID="TreeView1" runat="server" ImageSet="Arrows" Width="84px">
                                    <ParentNodeStyle Font-Bold="False" />
                                    <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
                                    <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px"
                                        VerticalPadding="0px" />
                                    <Nodes>
                                        <asp:TreeNode Text="招聘信息" Value="招聘信息">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=招聘信息"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=招聘信息"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="求职信息" Value="求职信息">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=求职信息"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=求职信息"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="培训信息" Value="培训信息">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=培训信息"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=培训信息"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="家教信息" Value="家教信息">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=家教信息"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=家教信息"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="公寓信息" Value="公寓信息">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=公寓信息"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=公寓信息"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="物品求购" Value="物品求购">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=物品求购"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=物品求购"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="物品出售" Value="物品出售">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=物品出售"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=物品出售"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="求兑出兑" Value="求兑出兑">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=求兑出兑"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=求兑出兑"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="车辆信息" Value="车辆信息">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=车辆信息"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=车辆信息"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="寻求合作" Value="寻求合作">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=寻求合作"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=寻求合作"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="企业广告" Value="企业广告">
                                            <asp:TreeNode Text="信息审核" Value="信息审核" NavigateUrl="~/BackGround/CheckInfo.aspx?id=企业广告"
                                                Target="mainFrame"></asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" NavigateUrl="~/BackGround/DeleteInfo.aspx?id=企业广告"
                                                Target="mainFrame"></asp:TreeNode>
                                        </asp:TreeNode>
                                        <asp:TreeNode Text="收费信息" Value="收费信息">
                                            <asp:TreeNode Text="信息发布" Value="信息发布" Target="mainFrame" NavigateUrl="~/BackGround/LeaguerInfo.aspx">
                                            </asp:TreeNode>
                                            <asp:TreeNode Text="信息删除" Value="信息删除" Target="mainFrame" NavigateUrl="~/BackGround/LeaguerInfoDelete.aspx">
                                            </asp:TreeNode>
                                        </asp:TreeNode>
                                    </Nodes>
                                    <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
                                        NodeSpacing="0px" VerticalPadding="0px" />
                                </asp:TreeView>
                            </td>
                            <td style="height: 374px; vertical-align: top;">
                                <iframe id="iframe1" name="mainFrame" style="width: 802px; height: 596px" frameborder="0">
                                </iframe>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td background="images/guanli_05.jpg" colspan="2" height="62" valign="top">
                    <table align="center" cellpadding="0" cellspacing="0" height="39" width="488">
                        <tr>
                            <td align="center" height="39">
                                <span class="huise">公司网址:www.mingri**ft.com &nbsp;&nbsp; 吉林省**科技有限公司 版权所有</span></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <!-- End ImageReady Slices -->
        <map name="Map">
            <area coords="820,63,906,89" href="../Default.aspx" shape="RECT" />
            <area coords="909,61,994,89" href="<%PageExit(); %>" shape="RECT" />
        </map>
    </form>

后台

public partial class BackGround_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                if (Session["UserName"].ToString().ToLower() != "TSOFT".ToLower())
                    WebMessageBox.Show("请登录后方可进入网站后台!", "../Logon.aspx");
            }
            catch { }
        }
    }
    public void PageExit()
    {
        Session["UserName"] = "";
        Response.Write("../Default.aspx");
    }
}

 

免费供求信息审核页面

主要使用gridview

0,1替换为不同文本(也可是图片)

多余字用。。。替代

表格中高亮显示

<form id="form1" runat="server">
    <div>
        <table style="width: 800px; height: 294px" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width: 755px; height: 13px" align="right">
                    <asp:Label ID="lblPageSum" runat="server" Style="left: 428px; top: 23px;" ></asp:Label>
                    <asp:RadioButton ID="rdoBtnCheckTrue" runat="server" AutoPostBack="True" GroupName="checkState"
                        OnCheckedChanged="rdoBtnCheckTrue_CheckedChanged" Text="已经审核供求信息" />
                    <asp:RadioButton ID="rdoBtnCheckFalse" runat="server" AutoPostBack="True" GroupName="checkState"
                        OnCheckedChanged="rdoBtnCheckFalse_CheckedChanged" Text="未审核供求信息" />
                    <asp:RadioButton ID="rdoBtnCheckAll" runat="server" AutoPostBack="True" Checked="True"
                        GroupName="checkState" OnCheckedChanged="rdoBtnCheckAll_CheckedChanged" Text="显示同类型所有供求信息" />
                    </td>
            </tr>
            <tr>
                <td style="vertical-align: top; width: 755px; height: 1px" align="center">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CellPadding="3" ForeColor="#333333" GridLines="None" Height="1px" OnPageIndexChanging="GridView1_PageIndexChanging"
            OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting"
            OnSelectedIndexChanging="GridView1_SelectedIndexChanging" Width="800px" PageSize="24">
            <PagerSettings FirstPageText="第一页" LastPageText="末一页" Mode="NextPreviousFirstLast"
                NextPageText="下一页" PreviousPageText="上一页" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <Columns>
                            <asp:BoundField DataField="type" HeaderText="信息类型">
                                <ItemStyle Width="60px" HorizontalAlign="Left" />
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="title" HeaderText="信息标题">
                                <ItemStyle Width="100px" HorizontalAlign="Left" />
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="info" HeaderText="信息内容" >
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="LinkMan" HeaderText="联系人">
                                <ItemStyle Width="60px" HorizontalAlign="Left" />
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="tel" HeaderText="联系电话">
                                <ItemStyle Width="80px" HorizontalAlign="Left" />
                                <HeaderStyle HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:BoundField DataField="checkState" HeaderText="审核状态">
                                <ItemStyle Width="60px" HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:CommandField DeleteText="详细信息" ShowDeleteButton="True">
                                <ItemStyle Width="60px" />
                            </asp:CommandField>
                            <asp:CommandField SelectText="通过/取消" ShowSelectButton="True">
                                <ItemStyle Width="60px" />
                            </asp:CommandField>
                        </Columns>
                        <RowStyle BackColor="#E3EAEB" />
                        <EditRowStyle BackColor="#7C6F57" />
                        <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="False" ForeColor="#333333" />
                        <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
   
    </div>
    </form>

后台

public partial class BackGround_CheckInfo : System.Web.UI.Page
{
    Operation operation = new Operation(); //业务类对象
    static string infoType = "";      //供求信息类型
    //DataSet dsCheckInfo = null;
    static int CheckType = -1;       //3种类别:全部显示(-1代表全部显示),显示未审核(0),显示审核(1)

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            infoType = Request.QueryString["id"].ToString();
            GridViewBind(infoType);
        }
    }
    /// <summary>
    /// 绑定供求信息到GridViev控件
    /// </summary>
    /// <param name="type">供求信息类别</param>
    private void GridViewBind(string type)
    {
        GridView1.DataSource = operation.SelectInfo(type);
        GridView1.DataKeyNames=new string[] {"id"};
        GridView1.DataBind();
        //显示当前页数
        lblPageSum.Text = "当前页为 " + (GridView1.PageIndex + 1) + " / " + GridView1.PageCount + " 页";
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)      行数据绑定后发生
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //高亮显示指定行
            e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#FFF000'");
            e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
            //设置审核状态,并且设置相应的颜色。


            if (e.Row.Cells[5].Text == "False")
            {
                e.Row.Cells[5].Text =StringFormat.HighLight("未审核",true);
            }
            else
            {
                e.Row.Cells[5].Text = StringFormat.HighLight("已审核", false);
            }
            //多余字 使用...显示
            e.Row.Cells[2].Text = StringFormat.Out(e.Row.Cells[2].Text, 18);
       

}
    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
        operation.UpdateInfo(id, infoType);
        //按审核类型绑定数据(3种类别:全部显示(-1),显示未审核(0),显示审核(1))
        switch (CheckType)
        {
            case -1:
                GridViewBind(infoType);
                break;
            case 0:
                GridView1.DataSource = operation.SelectInfo(infoType, false);
                GridView1.DataBind();
                break;
            case 1:
                GridView1.DataSource = operation.SelectInfo(infoType, true);
                GridView1.DataBind();
                break;
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)删除前发生,但这里不是删除,只是冒用它的东西写详细信息代码
    {
        string id = GridView1.DataKeys[e.RowIndex].Value.ToString();
        Response.Write("<script> window.open('DetailInfo.aspx?id=" + id + "&&type=" + infoType + "','','height=258, width=679, top=200, left=200') </script>");
        Response.Write("<script>history.go(-1)</script>");
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        //分页设置
        GridView1.PageIndex = e.NewPageIndex;
        //按审核类型绑定数据(3种类别:全部显示(-1),显示未审核(0),显示审核(1))
        switch (CheckType)
        {
            case -1:
                GridViewBind(infoType);
                break;
            case 0:
                GridView1.DataSource = operation.SelectInfo(infoType, false);
                GridView1.DataBind();
                break;
            case 1:
                GridView1.DataSource = operation.SelectInfo(infoType, true);
                GridView1.DataBind();
                break;
        }
        //显示当前页数
        lblPageSum.Text = "当前页为 " + (GridView1.PageIndex + 1) + " / " + GridView1.PageCount + " 页";
    }
    protected void rdoBtnCheckTrue_CheckedChanged(object sender, EventArgs e)
    {
        GridView1.PageIndex = 0;
        GridView1.DataSource = operation.SelectInfo(infoType, true);
        GridView1.DataBind();
        CheckType = 1;
        //显示当前页数
        lblPageSum.Text = "当前页为 " + (GridView1.PageIndex + 1) + " / " + GridView1.PageCount + " 页";
    }
    protected void rdoBtnCheckFalse_CheckedChanged(object sender, EventArgs e)
    {
        GridView1.PageIndex = 0;
        GridView1.DataSource = operation.SelectInfo(infoType, false);
        GridView1.DataBind();
        CheckType = 0;
        //显示当前页数
        lblPageSum.Text = "当前页为 " + (GridView1.PageIndex + 1) + " / " + GridView1.PageCount + " 页";
    }
    protected void rdoBtnCheckAll_CheckedChanged(object sender, EventArgs e)
    {
        GridView1.PageIndex = 0;
        GridViewBind(infoType);
        CheckType = -1;
        //显示当前页数
        lblPageSum.Text = "当前页为 " + (GridView1.PageIndex + 1) + " / " + GridView1.PageCount + " 页";
    }
}

免费信息删除后台


 <form id="form1" runat="server">
    <div align="right">
        <asp:Label ID="lblPageSum" runat="server" Text="当前页为 1 / 10 页"></asp:Label>
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            CellPadding="3" ForeColor="#333333" GridLines="None" Height="1px" OnPageIndexChanging="GridView1_PageIndexChanging"
            OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting"
            OnSelectedIndexChanging="GridView1_SelectedIndexChanging" Width="800px" PageSize="24">
            <PagerSettings FirstPageText="第一页" LastPageText="末一页" Mode="NextPreviousFirstLast"
                NextPageText="下一页" PreviousPageText="上一页" />
            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <Columns>
                <asp:BoundField DataField="type" HeaderText="信息类型">
                    <ItemStyle Width="60px" HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="title" HeaderText="信息标题">
                    <ItemStyle Width="100px" HorizontalAlign="Left" />
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="info" HeaderText="信息内容">
                    <HeaderStyle HorizontalAlign="Left" />
                    <ItemStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="LinkMan" HeaderText="联系人">
                    <ItemStyle Width="60px" HorizontalAlign="Left" />
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="tel" HeaderText="联系电话">
                    <ItemStyle Width="80px" HorizontalAlign="Left" />
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="checkState" HeaderText="审核状态">
                    <ItemStyle Width="60px" HorizontalAlign="Left" />
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:CommandField HeaderText="详细信息" SelectText="详细" ShowSelectButton="True">
                    <ItemStyle HorizontalAlign="Center" Width="60px" />
                </asp:CommandField>
                <asp:CommandField HeaderText="删除信息" ShowDeleteButton="True">
                    <ItemStyle HorizontalAlign="Center" Width="60px" />
                </asp:CommandField>
            </Columns>
            <RowStyle BackColor="#E3EAEB" />
            <EditRowStyle BackColor="#7C6F57" />
            <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="False" ForeColor="#333333" />
            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Right" />
            <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:GridView>
        </div>
    </form>
</body>

 

public partial class BackGround_DeleteInfo : System.Web.UI.Page
{
    Operation operation = new Operation(); //业务类对象
    static string infoType = "";      //供求信息类型

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            infoType = Request.QueryString["id"].ToString();
            GridViewBind(infoType);
        }
    }
    /// <summary>
    /// 绑定供求信息到GridViev控件
    /// </summary>
    /// <param name="type">供求信息类别</param>
    private void GridViewBind(string type)
    {
        GridView1.DataSource = operation.SelectInfo(type);
        GridView1.DataKeyNames = new string[] { "id" };
        GridView1.DataBind();
        //显示当前页数
        lblPageSum.Text = "当前页为 " + (GridView1.PageIndex + 1) + " / " + GridView1.PageCount + " 页";
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //高亮显示指定行
            e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#FFF000'");
            e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
            //设置审核状态,并且设置相应的颜色。
            if (e.Row.Cells[5].Text == "False")
            {
                e.Row.Cells[5].Text = StringFormat.HighLight("未审核", true);
            }
            else
            {
                e.Row.Cells[5].Text = StringFormat.HighLight("已审核", false);
            }
            //多余字 使用...显示
            e.Row.Cells[2].Text = StringFormat.Out(e.Row.Cells[2].Text, 18);
            //删除指定行数据时,弹出询问对话框。将属性添加到服务器控件的方法,学着点
            ((LinkButton)(e.Row.Cells[7].Controls[0])).Attributes.Add("onclick", "return confirm('是否删除当前行数据!')");
        }
    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {
        string id = GridView1.DataKeys[e.NewSelectedIndex].Value.ToString();
        Response.Write("<script> window.open('DetailInfo.aspx?id=" + id + "&&type=" + infoType + "','','height=258,width=679,top=200,left=200') </script>");
        Response.Write("<script>history.go(-1)</script>");
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        GridViewBind(infoType);
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        operation.DeleteInfo(GridView1.DataKeys[e.RowIndex].Value.ToString());
        GridViewBind(infoType);
    }
}

 

 

 

 


 

posted @ 2009-04-14 00:10  minmin8110  阅读(1073)  评论(0)    收藏  举报