用那个控件方便控制?如有代码提供下参考谢谢

解决方案 »

  1.   

    用vs自带的列表控件,winform的自带分页,不过比较丑
      

  2.   


    我是写网页 datalist吗 怎么用呢 一头雾水
      

  3.   

    网页的话,我没怎么做过,做过的网页也不是使用datalist做的,我用的是repeater
    给你一个使用repeater的页面代码,
    后台:using System;
    using System.Data;
    using System.Configuration;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using CRM.Entity.ZW;
    using CRM.Entity.Kuke;
    using CRM.IBLL;
    using CRM.Factory;public partial class Default2 : System.Web.UI.Page
    {
        protected static IList<CRM_Service> list = null;
        protected static PagedDataSource pds = null;
        ICRM_ServiceBLL icrm_service_bll = BLLFactory.CreateCRM_ServiceBLL();
        ICRM_ServiceTypeBLL icrm_servietype_bll = BLLFactory.CreateCRM_ServiceTypeBLL();
        string status = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                pds = new PagedDataSource();
                ViewState["CurrentPage"] = 0;
                ViewState["type"] = "";
                status=Request.QueryString["status"];
            //PopWiatnOperate.ShowPopWin(PopupWin1, "提示", "本页查看所有已反馈服务", EeekSoft.Web.PopupColorStyle.Blue);
            }
                list = icrm_service_bll.GetAllService("", "", "", status, "", "");            databind();
        }
        //保存分页
        protected int CurrentPage
        {
            get
            {
                return (int)ViewState["CurrentPage"];
            }
            set
            {
                ViewState["CurrentPage"] = value;
            }
        }
        //保存查询条件:类型
        protected string Type
        {
            get { return ViewState["type"].ToString(); }
            set { ViewState["type"] = value; }
        }    private void SetEnable(PagedDataSource pds)
        {
            lbtnPrev.Enabled = true;
            lbtnNext.Enabled = true;
            lbtnFirst.Enabled = true;
            lbtnLast.Enabled = true;
            if (pds.IsFirstPage)
            {
                lbtnPrev.Enabled = false;
                lbtnFirst.Enabled = false;
            }
            if (pds.IsLastPage)
            {
                lbtnLast.Enabled = false;
                lbtnNext.Enabled = false;
            }
        }
        protected void databind()
        {
            pds.DataSource = list;
            if (list.Count == 0)
                divData.Visible = true;
            else
                divData.Visible = false;
            pds.AllowPaging = true;
            pds.PageSize = 10;
            pds.CurrentPageIndex = CurrentPage;
            lblCurrentPage.Text = "共" + "<B><font color='Red'>" + (list.Count) +
               "</font></B>条记录 每页<B><font color='Red'>10</font></B>条 第" + "<B><font color='Red'>" + (pds.CurrentPageIndex + 1) + "</font></B>页/共" + "<B><font color='Red'>" + pds.PageCount + "</font></B>页";
            ddlPageNo.Items.Clear();
            for (int i = 1; i <= pds.PageCount; i++)
            {            ddlPageNo.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            SetEnable(pds);
            Repeater1.DataSource = pds;
            Repeater1.DataBind();
            IList<CRM_DicForService> typeList = icrm_servietype_bll.GetAllServiceType();
            ddlType.Items.Clear();
            ddlType.Items.Add(new ListItem("--请选择--", ""));
            foreach (CRM_DicForService stype in typeList)
            {
                ListItem item = new ListItem();
                item.Value = stype.TypeValue;
                item.Text = stype.TypeItem;
                ddlType.Items.Add(item);
            }
            ddlType.SelectedValue = Type;
        }
        protected void lbtnFirst_Click(object sender, EventArgs e)
        {
            CurrentPage = 0;
            databind();
        }
        protected void lbtnPrev_Click(object sender, EventArgs e)
        {
            CurrentPage--;
            databind();
        }
        protected void lbtnNext_Click(object sender, EventArgs e)
        {
            CurrentPage++;
            databind();
        }
        protected void lbtnLast_Click(object sender, EventArgs e)
        {
            CurrentPage = pds.PageCount - 1;
            databind();
        }    protected void btnGO_Click(object sender, EventArgs e)
        {
            CurrentPage = int.Parse(ddlPageNo.SelectedValue) - 1;
            databind();
        }
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            string customerName = txtCustomer.Text;
            string title = txtTitle.Text;
            string begin = string.Empty;
            string end = string.Empty;
            if (begintime.Text != null && !begintime.Text.Equals(""))
            {
                begin = begintime.Text;
            }
            if (endtime.Text != null && !endtime.Text.Equals(""))
            {
                end = endtime.Text;
            }
            Type = ddlType.SelectedValue;
            list = icrm_service_bll.GetAllService(customerName, title, Type, "已反馈", begin, end);
            databind();
        }
    }
      

  4.   

    前台<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
        CodeFile="PageOnHolelist.aspx.cs" Inherits="Default2" Title="Untitled Page" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">    <script type="text/jscript">
            function mouseoverBG(row)
            { 
                row.style.backgroundColor="#3399ff";
                row.style.color="white";
            }
            function AmouseoutBG(row)
            {
                row.style.backgroundColor="#cbd9ea";
                row.style.color="black";
            }
            function mouseoutBG(row)
            {
                row.style.backgroundColor="white";
                row.style.color="black";
            }
        </script>    <%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>--%>    <script language="javascript" type="text/javascript" src="../My97DatePicker/WdatePicker.js"
            charset="gb2312"></script>    <table class="tables" style="width: 90%;">
            <tr>
                <td colspan="6" style="font-weight: bold; font-size: 14px; vertical-align: middle;
                    height: 14px; background-color: #3399ff; text-align: left;">
                    <img alt="" src="../images/menu/ns_doc_sel.gif" />服务管理 &gt; 服务归档</td>
            </tr>
            <tr style="text-align: right">
                <td colspan="6">
                    <asp:Button ID="btnSelect" CssClass="button" runat="server" Text="列出符合条件的服务" OnClick="btnSelect_Click"
                        Width="126px" /></td>
            </tr>
            <tr>
                <td class="tr_Head">
                    客户名称:</td>
                <td style="width: 12%; height: 14px">
                    <asp:TextBox ID="txtCustomer" runat="server" Width="96%"></asp:TextBox></td>
                <td class="tr_Head">
                    概要:</td>
                <td style="width: 12%; height: 14px">
                    <asp:TextBox ID="txtTitle" runat="server" Width="97%"></asp:TextBox></td>
                <td class="tr_Head">
                    服务类型:</td>
                <td style="width: 12%; height: 14px">
                    <asp:DropDownList ID="ddlType" runat="server" Width="97%">
                    </asp:DropDownList></td>
            </tr>
            <tr>
                <td class="tr_Head">
                    起止日期:</td>
                <td colspan="5" style="width: 12%; height: 14px">
                    <asp:TextBox ID="begintime" runat="server" CssClass="Wdate" onFocus="new WdatePicker(this,'%Y-%M-%D',true,'default')"
                        Width="47%"></asp:TextBox>
                    -
                    <asp:TextBox ID="endtime" runat="server" CssClass="Wdate" onFocus="new WdatePicker(this,'%Y-%M-%D',true,'default')"
                        Width="48%"></asp:TextBox></td>
            </tr>
            <tr>
                <td colspan="6" align="center" style="vertical-align: top; height: 300px">
                    <asp:Repeater ID="Repeater1" runat="server">
                        <HeaderTemplate>
                            <table style="font-size: 12px; border-right: #0099ff 1px solid; border-top: #0099ff 1px solid;
                                border-left: #0099ff 1px solid; border-bottom: #0099ff 1px solid; border-spacing: 1px;
                                width: 100%;">
                                <tr class="trs" style="width: 100%;">
                                    <th align="center">
                                        服务编号</th>
                                    <th align="center">
                                        客户名称</th>
                                    <th align="center">
                                        客户联系方式</th>
                                    <th align="center">
                                        概要</th>
                                    <th align="center">
                                        服务类型</th>
                                    <th align="center">
                                        创建人</th>
                                    <th align="center">
                                        创建时间</th>
                                    <th align="center">
                                        状态</th>
                                    <th align="center">
                                        操作</th>
                                </tr>
                        </HeaderTemplate>
                        <ItemTemplate>
                            <tr onmousemove="mouseoverBG(this)" onmouseout="AmouseoutBG(this)" style="width: 100%;
                                background-color: #cbd9ea;">
                                <td>
                                    <asp:Label ID="lblNO" runat="server" Text='<%# Eval("ServiceID") %>'></asp:Label></td>
                                <td>
                                    <%# Eval("customerNo") %>
                                </td>
                                <td>
                                    <%# Eval("customerPhone") %>
                                </td>
                                <td>
                                    <%# Eval("ServiceTitle") %>
                                </td>
                                <td>
                                    <%# Eval("SType") %>
                                </td>
                                <td>
                                    <%# Eval("ServiceBuilder.UserName") %>
                                </td>
                                <td>
                                    <%# Eval("ServicerBuildTime") %>
                                </td>
                                <td>
                                    <asp:Label ID="lblstatus" runat="server" Text='<%# Eval("SState") %>'></asp:Label></td>
                                <td>
                                    <asp:ImageButton ID="ibOperate" runat="server" ImageUrl="~/images/bt_feedback.gif"
                                        PostBackUrl='<%# Eval("ServiceID","~/ZW/PageOnHole.aspx?sid={0}") %>' AlternateText="服务归档" />
                                </td>
                            </tr>
                        </ItemTemplate>
                        <AlternatingItemTemplate>
                            <tr onmousemove="mouseoverBG(this)" onmouseout="mouseoutBG(this)" style="width: 100%;">
                                <td>
                                    <asp:Label ID="lblNO" runat="server" Text='<%# Eval("ServiceID") %>'></asp:Label></td>
                                <td>
                                    <%# Eval("customerNo") %>
                                </td>
                                <td>
                                    <%# Eval("customerPhone") %>
                                </td>
                                <td>
                                    <%# Eval("ServiceTitle") %>
                                </td>
                                <td>
                                    <%# Eval("SType") %>
                                </td>
                                <td>
                                    <%# Eval("ServiceBuilder.UserName") %>
                                </td>
                                <td>
                                    <%# Eval("ServicerBuildTime") %>
                                </td>
                                <td>
                                    <asp:Label ID="lblstatus" runat="server" Text='<%# Eval("SState") %>'></asp:Label></td>
                                <td>
                                    <asp:ImageButton ID="ibOperate" runat="server" ImageUrl="~/images/bt_feedback.gif"
                                        PostBackUrl='<%# Eval("ServiceID","~/ZW/PageOnHole.aspx?sid={0}") %>' AlternateText="服务归档" />
                                </td>
                            </tr>
                        </AlternatingItemTemplate>
                        <FooterTemplate>
                            </table>
                        </FooterTemplate>
                    </asp:Repeater>
                    <div id="divData" runat="server" visible="false">
                        <img alt="无数据项" src="../images/nodata.JPG" style="width: 100%; height: 70px;" /></div>
                </td>
            </tr>
            <tr>
                <td colspan="6" align="right" style="color: Blue;">
                    &nbsp;<asp:Label ID="lblCurrentPage" runat="server" Text=""></asp:Label>
                    <asp:LinkButton ID="lbtnFirst" runat="server" OnClick="lbtnFirst_Click" CssClass="lbl">首页</asp:LinkButton>
                    <asp:LinkButton ID="lbtnPrev" runat="server" OnClick="lbtnPrev_Click" CssClass="lbl">上一页</asp:LinkButton>
                    <asp:LinkButton ID="lbtnNext" runat="server" OnClick="lbtnNext_Click" CssClass="lbl">下一页</asp:LinkButton>
                    <asp:LinkButton ID="lbtnLast" runat="server" OnClick="lbtnLast_Click" CssClass="lbl">尾页</asp:LinkButton>&nbsp;
                    转到<asp:DropDownList ID="ddlPageNo" runat="server">
                    </asp:DropDownList>页
                    <asp:Button ID="btnGO" runat="server" CssClass="button" OnClick="btnGO_Click" Text="GO" Width="24px" />
                    <%--</asp:UpdatePanel>
            </ContentTemplate>--%>
                </td>
            </tr>
        </table>
    </asp:Content>