RT,  (顺便散散分~)
不说多了
代码下这是 数据控件的代码: 适合IList 泛型的
YsmvRepeater.csusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
using System.Collections;namespace YSMV.Control
{
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:YsmvRepeater runat=\"server\" AllowPage=\"true\" PageSize=\"10\" ShowPage=\"true\"></{0}:YsmvRepeater>")]
    public class YsmvRepeater : Repeater
    {
       
        //Static param
        private static readonly Regex RX;
        private static readonly object EventPageChanged;        static YsmvRepeater()
        {
            RX = new Regex(@"^&page=\d+", RegexOptions.Compiled);
            EventPageChanged = new object();
        }        //Static constants
        protected const string HTML1 = "<table cellpadding=0 cellspacing=0 class='inputTable'><tr><td colspan=2>";
        protected const string HTML2 = "</td></tr><tr><td class=paging align=left>";
        protected const string HTML3 = "</td><td align=right class=paging>";
        protected const string HTML4 = "</td></tr></table>";
        private const string LINK_PREV = "<a href=?page={0}>&#060;&nbsp;Previous</a>";
        private const string LINK_MORE = "<a href=?page={0}>More&nbsp;&#062;</a>";
        private const string KEY_PAGE = "page";
        private const string COMMA = "?";
        private const string AMP = "&";        protected string emptyText;
        private IList dataSource;
        private int pageSize = 10;
        private int currentPageIndex;
        private int itemCount;
        private bool allowPage = false;
        private bool showPage = true;        [Browsable(true)
        , Category("Appearance"),
        DefaultValue(true),
        Description("是否显示翻页链接")
        ]
        public bool ShowPage
        {
            get { return showPage; }
            set { showPage = value; }
        }
        [Browsable(true),
        Category("Appearance"),
        DefaultValue(true),
        Description("是否允许分页")]
        public bool AllowPage
        {
            get { return allowPage; }
            set { allowPage = value; }
        }
        [Browsable(true),
        Category("Appearance"),
        DefaultValue(10),
        Description("每页显示的数量")
        ]
        public int PageSize
        {
            get { return pageSize; }
            set { pageSize = value; }
        }
        [Browsable(true),
        Category("Appearance"),
        DefaultValue(""),
        Description("无记录时候显示的内容")]
        public string EmptyText
        {
            set { emptyText = value; }
        }
        override public object DataSource
        {
            set
            {
                //This try catch block is to avoid issues with the VS.NET designer
                //The designer will try and bind a datasource which does not derive from ILIST
                try
                {
                    dataSource = (IList)value;
                    ItemCount = dataSource.Count;
                }
                catch
                {
                    dataSource = null;
                    ItemCount = 0;
                }
            }
        }
        protected int PageCount
        {
            get { return (ItemCount - 1) / pageSize; }
        }        virtual public int ItemCount
        {
            get { return itemCount; }
            set
            {itemCount = value;}
        }        virtual public int CurrentPageIndex
        {
            get { return currentPageIndex; }
            set { currentPageIndex = value; }
        }        public void SetPage(int index)
        {
            //OnPageIndexChanged(new DataGridPageChangedEventArgs(null, index));
            OnPageIndexChanged(new GridViewPageEventArgs(index));
        }        override protected void OnLoad(EventArgs e)
        {
            if (Visible)
            {
                string page = Context.Request[KEY_PAGE];
                int index = (page != null) ? int.Parse(page) : 0;
                SetPage(index);
            }
        }        /// <summary>
        /// Overriden method to control how the page is rendered
        /// </summary>
        /// <param name="writer"></param>
        override protected void Render(HtmlTextWriter writer)
        {            //Check there is some data attached
            string page = Context.Request[KEY_PAGE];
            int index = (page != null) ? int.Parse(page) : 0;
            if (ItemCount == 0)
            {
                writer.Write(emptyText);
                return;
            }
            //Mask the query
            string query = Context.Request.Url.Query.Replace(COMMA, AMP);
            query = RX.Replace(query, string.Empty);            // Write out the first part of the control, the table header
            writer.Write(HTML1);            // Call the inherited method
            base.Render(writer);            // Write out a table row closure
            writer.Write(HTML2);            //Determin whether next and previous buttons are required
            //Previous button?
            if (currentPageIndex > 0)
            {
                if (ShowPage)
                    writer.Write(string.Format(LINK_PREV, (currentPageIndex - 1) + query));
            }            //Close the table data tag
            writer.Write(HTML3);            //Next button?
            if (currentPageIndex < PageCount)
            {
                if (ShowPage)
                    writer.Write(string.Format(LINK_MORE, (currentPageIndex + 1) + query));
            }            //Close the table
            writer.Write(HTML4);
        }        override protected void OnDataBinding(EventArgs e)
        {
            if (!allowPage)
            {
                base.DataSource = dataSource;
                base.OnDataBinding(e);
                return;
            }
            //Work out which items we want to render to the page
            int start = CurrentPageIndex * pageSize;
            int size = Math.Min(pageSize, ItemCount - start);            IList page = new ArrayList();            //Add the relevant items from the datasource
            for (int i = 0; i < size; i++)
                page.Add(dataSource[start + i]);            //set the base objects datasource
            base.DataSource = page;
            base.OnDataBinding(e);        }        //public event DataGridPageChangedEventHandler PageIndexChanged;
        public event GridViewPageEventHandler PageIndexChanged
        {
            add
            {
                Events.AddHandler(EventPageChanged, value);
            }
            remove
            {
                Events.RemoveHandler(EventPageChanged, value);
            }
        }
        virtual protected void OnPageIndexChanged(GridViewPageEventArgs e)
        {
            GridViewPageEventHandler pagehandler = (GridViewPageEventHandler)Events[EventPageChanged];
            if (pagehandler != null)
                pagehandler(this, e);
        }
    }
}

解决方案 »

  1.   

    同事配合我  写了 一个分页的 不错:
    using System;
    using System.Data;
    using System.Configuration;
    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 System.Text.RegularExpressions;namespace YSMV.WEB
    {
        /// <summary>
        /// PagerControl 的摘要说明
        /// </summary>
        public class PagerControl : System.Web.UI.Control
        {
            static PagerControl()
            {
                RX = new Regex(@"^&page=\d+", RegexOptions.Compiled);
            }
            private int _pageSize;        public int PageSize
            {
                get { return _pageSize; }
                set { _pageSize = value; }
            }
            private int _pageCount;        public int PageCount
            {
                get { return _pageCount; }
                set { _pageCount = value; }
            }        private static readonly Regex RX;
            private string query;
            private int curretPage;
            private int myPageCount;
            public PagerControl()
            {
                query = Context.Request.Url.Query.Replace("?", "&");
                query = RX.Replace(query, string.Empty);
                string myPage = Context.Request["page"];
                if (string.IsNullOrEmpty(myPage))
                    curretPage = 0;
                else
                {
                    try
                    {
                        curretPage = int.Parse(myPage);
                    }
                    catch
                    {
                        Context.Response.Redirect(Regex.Replace(Context.Request.Url.ToString(), @"page=[^&]+", "page=0"));
                    }
                }
            }
            protected override void Render(HtmlTextWriter writer)
            {
                if ((this._pageCount % this._pageSize) == 0)
                {
                    myPageCount = this._pageCount / this._pageSize;
                }
                else
                    myPageCount = this._pageCount / this._pageSize + 1;
                string str = "<div class='digg'>";
                if (this._pageSize > this._pageCount)
                {
                    str += "";
                }
                else
                {
                    if (this._pageCount <= this._pageSize * 10)
                    {
                        if (this.curretPage == 0)
                            str += "<span class='disabled'> < </span>";
                        else
                            str += "<a href='?page=" + (curretPage - 1) + this.query + "'> < </a>";
                        for (int i = 0; i < myPageCount; i++)
                        {
                            if (curretPage == i)
                                str += "<span class='current'>" + (i + 1) + "</span>";
                            else
                                str += "<a href='?page=" + i + this.query + "'>" + (i + 1) + "</a>";
                        }
                        if (this.curretPage < myPageCount - 1)
                            str += "<a href='?page=" + (curretPage + 1) + this.query + "'> > </a>";
                        else
                            str += "<span class='disabled'> > </span>";
                    }
                    else
                    {
                        if (this.curretPage == 0)
                            str += "<span class='disabled'> < </span>";
                        else
                            str += "<a href='?page=" + (curretPage - 1) + this.query + "'> < </a>";
                        if (this.curretPage < 4)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if (curretPage == i)
                                    str += "<span class='current'>" + (i + 1) + "</span>";
                                else
                                    str += "<a href='?page=" + i + this.query + "'>" + (i + 1) + "</a>";
                            }
                            str += "...<a href='?page=" + myPageCount + this.query + "'>" + myPageCount + "</a>";
                        }
                        else if (this.curretPage >= 4 && this.curretPage < myPageCount - 6)
                        {
                            str += "<a href='?page=1" + this.query + "'>1</a>...";
                            for (int i = -2; i < 3; i++)
                            {
                                if (i == 0)
                                    str += "<span class='current'>" + (this.curretPage + 1) + "</span>";
                                else
                                    str += "<a href='?page=" + (this.curretPage + i) + this.query + "'>" + (this.curretPage + 1 + i) + "</a>";
                            }
                            str += "...<a href='?page=" + (myPageCount-1) + this.query + "'>" + myPageCount + "</a>";
                        }
                        else if(curretPage>myPageCount+1)
                        {
                            Context.Response.Redirect(Regex.Replace(Context.Request.Url.ToString(), @"page=\d+", "page=" + (myPageCount-1)));
                        }
                        else
                        {
                            str += "<a href='?page=1" + this.query + "'>1</a>...";
                            for (int i = 6; i > 0; i--)
                            {
                                if (curretPage == myPageCount - i)
                                    str += "<span class='current'>" + (myPageCount - i + 1) + "</span>";
                                else
                                    str += "<a href='?page=" + (myPageCount - i) + this.query + "'>" + (myPageCount - i + 1) + "</a>";
                            }
                        }
                        if (this.curretPage < myPageCount - 1)
                            str += "<a href='?page=" + (curretPage + 1) + this.query + "'> > </a>";
                        else
                            str += "<span class='disabled'> > </span>";                }
                }
                str += "</div>";
                writer.Write(str);
            }
        }
    }
      

  2.   

    这是分页控件的 css#leftMenu a{width:90%; height:30px; border-bottom:1px dashed #7dbbe0; float:left; text-align:center; line-height:30px; font-size:15px;color:Black; text-decoration:none; margin-bottom:5px;}
    #leftMenu a:hover{width:100%; height:30px; border-bottom:1px solid #7dbbe0; float:left; text-align:center; line-height:30px; font-size:17px;color:White; background-color:#7dbbe0; font-weight:bolder}
    #leftMenu a:active{width:100%; height:30px; border-bottom:1px solid #7dbbe0; float:left; text-align:center; line-height:30px; font-size:15px;color:White;background-color:#7dbbe0;}
    /*分页控件样式*/DIV.digg {
    PADDING-RIGHT: 3px; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; MARGIN: 3px; PADDING-TOP: 3px; TEXT-ALIGN: right;
    }
    DIV.digg A {
    BORDER-RIGHT: #aaaadd 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #aaaadd 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #aaaadd 1px solid; COLOR: #000099; PADDING-TOP: 2px; BORDER-BOTTOM: #aaaadd 1px solid; TEXT-DECORATION: none
    }
    DIV.digg A:hover {
    BORDER-RIGHT: #000099 1px solid; BORDER-TOP: #000099 1px solid; BORDER-LEFT: #000099 1px solid; COLOR: #000; BORDER-BOTTOM: #000099 1px solid
    }
    DIV.digg A:active {
    BORDER-RIGHT: #000099 1px solid; BORDER-TOP: #000099 1px solid; BORDER-LEFT: #000099 1px solid; COLOR: #000; BORDER-BOTTOM: #000099 1px solid
    }
    DIV.digg SPAN.current {
    BORDER-RIGHT: #000099 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #000099 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #000099 1px solid; COLOR: #fff; PADDING-TOP: 2px; BORDER-BOTTOM: #000099 1px solid; BACKGROUND-COLOR: #000099
    }
    DIV.digg SPAN.disabled {
    BORDER-RIGHT: #eee 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #eee 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; BORDER-LEFT: #eee 1px solid; COLOR: #ddd; PADDING-TOP: 2px; BORDER-BOTTOM: #eee 1px solid
    }
      

  3.   

    使用方法:
    在页头加上
    <%@ Register Assembly="YSMV.Control" Namespace="YSMV.Control" TagPrefix="cc2" %>
    由于控件是继承自Repeater 所以可以 像你平常对待Repeater 一样
    <cc2:YsmvRepeater ID="yr_Category" runat="server" AllowPage="true" PageSize="10"
                    ShowPage="false" OnPageIndexChanged="CustomRepeater1_PageIndexChanged" EmptyText="没有记录">
                    <HeaderTemplate>
                            <tr align="center" style="width: 100%">
                                <td colspan="6">
                                    <div class="column">
                                        类目一览</div>
                                    <div>
                                </td>
                            </tr>
                            <tr align="center">
                                <td style="font-weight: bold;">
                                    编号</td>
                                <td style="font-weight: bold;">
                                    类目名称</td>
                                <td style="font-weight: bold;">
                                    类目操作</td>
                                <td style="font-weight: bold;">
                                    子类操作</td>
                                <td style="font-weight: bold;">
                                    属性列表</td>
                                <td style="font-weight: bold;">
                                    产品列表
                                </td>
                            </tr>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <tr align="center">
                            <td>
                                <%# Eval("Id") %>
                            </td>
                            <td align="left">
                                <asp:Label runat="server" ID="lbl_Name" Text='<%# Eval("Name") %>'></asp:Label>
                            </td>
                            <td>
                                <a href="CategoryEdit.aspx?id=<%# Eval("Id") %>">编辑</a> <a href="CategoryDel.aspx?id=<%# Eval("Id") %>"
                                    onclick="return confirm('确认删除吗?')">删除</a>
                            </td>
                            <td>
                                <a href="CategoryAdd.aspx?id=<%# Eval("Id") %>">添加子类</a>
                            </td>
                            <td>
                                <a href="Properties.aspx?Id=<%# Eval("Id") %>&Name=<%# HttpUtility.UrlEncode(StringFormat.FormatCategoryName(Eval("Name").ToString())) %>">属性</a>
                            </td>
                            <td>
                                <a href="Goods.aspx?id=<%# Eval("Id") %>">产品类表</a>
                            </td>
                        </tr>
                    </ItemTemplate>
                </cc2:YsmvRepeater>
                <Ysmv:PagerControl runat="server" ID="p1" PageSize="10">
                </Ysmv:PagerControl>
    可以看到 有  一个出发 PageChanged 的事件
    后台.cs        protected void CustomRepeater1_PageIndexChanged(object sender, GridViewPageEventArgs e)
            {
                yr_Category.CurrentPageIndex = e.NewPageIndex;//指定当前页
                yr_Category.DataSource = //这个你应该知道了
                yr_Category.DataBind();
                p1.PageCount = yr_Category.ItemCount;//给分页控件 你的记录数
            }去看看吧 效果还不错,不过我没有处理他的回发事件 因为在 触发前后 都重新绑定了数据源,所以不要再里面加入Button 的事件
    毕竟是给前台用的 呵呵~
      

  4.   

    这是我们做的 一个上传控件 是用来个FTP 上传的
    我们经常要用到  比如 一个专门放静态资源的  img.xx.com  可能就用到了我这个控件代码:先在web.config加上<configSections>
    <!--Register a FtpConfig -->
    <section name="FtpConfig" type="System.Configuration.SingleTagSectionHandler"/>
    </configSections>
    <FtpConfig Server="192.168.1.111" Port="21" UserName="mars" Password="mars" RootPath=""/>
    System.Configuration.SingleTagSectionHandler 这个类大家可以去看看 msdn 的解释
    然后处理下你从wen.config 获取的 配置
      

  5.   

    FtpConfig.cs
    using System;
    using System.Data;
    using System.Configuration;
    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 System.Collections;
    using System.Net;/// <summary>
    /// FtpConfig 的摘要说明
    /// </summary>
    namespace YSMV.WEB
    {
        public class FtpConfig
        {
            public FtpConfig()
            {
                //
                // TODO: 在此处添加构造函数逻辑
                //
            }
            #region Get the ftpconfig from the web.config        //Get the configSections from the app/web.config
            private IDictionary config = ConfigurationManager.GetSection("FtpConfig") as IDictionary;        // Internal member variables        //Server Ip Address
            public string Server
            {
                get { return config["Server"].ToString(); }
            }
            //Server Port,default value is 21
            public string Port
            {
                get { return config["Port"].ToString(); }
            }
            //Server UserName
            public string Username
            {
                get { return config["UserName"].ToString(); }
            }
            //Server Password
            public string Password
            {
                get { return config["Password"].ToString(); }
            }
            //Server Root Path
            public string Rootpath
            {
                get { return config["RootPath"].ToString(); }
            }        //Return a passport interface for the web client users
            public ICredentials Credentials
            {
                get
                {
                    return new NetworkCredential(Username, Password);
                }
            }        /// <summary>
            /// Get the uri with a param filepath
            /// </summary>
            /// <param name="relationFilePath">filepath</param>
            /// <returns></returns>
            public Uri GetFtpUri(string relationFilePath)
            {
                string uriString = string.Empty;
                if (Rootpath != "")
                {
                    uriString = string.Format("ftp://{0}:{1}/%2f{2}/{3}", Server, Port, Rootpath, relationFilePath);
                }
                else
                {
                    uriString = string.Format("ftp://{0}:{1}/%2f{2}", Server, Port, relationFilePath);
                }
                Uri uri = new Uri(uriString);
                return uri;        }
            #endregion
        }
    }
      

  6.   

    处理类
    FtpManage.cs
    using System;
    using System.Data;
    using System.Configuration;
    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 System.Net;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;namespace YSMV.WEB
    {
        public class FtpManage
        {
            private static Regex reg = new Regex(@"[^\s]*$", RegexOptions.Compiled);
            public FtpConfig config = new FtpConfig();        /// <summary>
            /// Check file/folder exists or not
            /// </summary>
            /// <param name="parentpath">Parent path</param>
            /// <param name="name">File/Folder name</param>
            /// <returns>Exist or not</returns>
            public bool Exists(string parentpath, string name)
            {
                try
                {
                    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(config.GetFtpUri(parentpath));
                    request.Credentials = config.Credentials;
                    request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
                    Stream stream = request.GetResponse().GetResponseStream();
                    using (StreamReader sr = new StreamReader(stream, Encoding.Default))
                    {
                        string str = sr.ReadLine();
                        while (str != null)
                        {
                            GroupCollection gc = reg.Match(str).Groups;
                            if (gc.Count != 1)
                            {
                                return false;
                            }
                            string path = gc[0].Value;
                            if (path == name)
                                return true;
                            str = sr.ReadLine();                    }
                    }
                    stream.Dispose();
                    return false;
                }
                catch
                {
                    return false;
                }
            }
            /// <summary>
            /// Create Directory 
            /// </summary>
            /// <param name="parentpath">Parent path</param>
            /// <param name="foldername">New Folder name</param>
            /// <returns>Success or not</returns>
            public bool CreateDirectory(string parentpath, string foldername)
            {
                try
                {
                    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(config.GetFtpUri(string.Format("{0}/{1}", parentpath, foldername)));
                    request.Credentials = config.Credentials;
                    request.Method = WebRequestMethods.Ftp.MakeDirectory;
                    FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            /// <summary>
            /// Upload a file to the ftp server
            /// </summary>
            /// <param name="path">folder*/filename</param>
            /// <param name="stream">Get the ftp request stream</param>
            /// <returns>Success or not</returns>
            public bool UploadFile(string path, Stream stream)
            {
                try
                {
                    FtpWebRequest request = (FtpWebRequest)WebRequest.Create(config.GetFtpUri(path));
                    request.Credentials = config.Credentials;
                    request.Method = WebRequestMethods.Ftp.UploadFile;
                    using (Stream write = request.GetRequestStream())
                    {
                        byte[] buffer = new byte[2048];
                        int length = buffer.Length;
                        int i = stream.Read(buffer, 0, length);
                        while (i > 0)
                        {
                            write.Write(buffer, 0, length);
                            i = stream.Read(buffer, 0, length);
                        }
                        write.Close();
                        write.Dispose();
                    }
                    stream.Close();
                    stream.Dispose();
                    return true;
                }
                catch
                {
                    return false;
                }
            }
        }
    }
      

  7.   

    UploadControl.cs
    这是 控件了 继承自 fileuploadusing System;
    using System.Data;
    using System.Configuration;
    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 System.IO;/// <summary>
    /// UploadControl 的摘要说明
    /// </summary>
    namespace YSMV.WEB
    {    public class UploadControl : FileUpload
        {
            public UploadControl() { }
            public string Allowext
            {
                get { return ConfigurationManager.AppSettings["ImageAllowExt"].ToString(); }
            }
            public string Mime
            {
                get { return ConfigurationManager.AppSettings["ImageMime"].ToString(); }
            }        private string _uploadfilepath = null;
            public string Uploadfilepath
            {
                get { return _uploadfilepath; }
            }
            /// <summary>
            /// Save the File
            /// </summary>
            /// <param name="parentpath">The file saved in which folder</param>
            /// <returns>Enum Result</returns>
            public Result Save(string parentpath, int size, bool create)
            {
                FtpManage manage = new FtpManage();
                if (!this.HasFile)
                    return Result.NoneFile;
                if (Allowext.IndexOf((Path.GetExtension(this.FileName)).ToLower()) == -1)
                    return Result.ForbidExtension;
                if (Mime.IndexOf(this.PostedFile.ContentType.ToLower()) == -1)
                    return Result.ForbidMime;
                if (this.PostedFile.ContentLength / 1024 > size)
                    return Result.InvalidSize;
                string dayPath = DateTime.Today.ToString("yyyyMMdd");
                string [] allpaths=parentpath.Split(new char[]{'/'});
                int allpathslength = allpaths.Length;
                if (allpathslength > 0)
                {
                    string innerpath = null;
                    for (int i = 0; i < allpathslength; i++)
                    {
                        if (i == 0)
                        {
                            if (!manage.Exists(string.Empty, allpaths[0]))
                            {
                                if (!create)
                                    return Result.NoneDirectory;
                                else
                                {
                                    if (!manage.CreateDirectory(string.Empty, allpaths[0]))
                                        return Result.Systembusy;
                                }
                            }
                        }
                        else
                        {
                            if (i == 1)
                                innerpath += allpaths[i - 1];
                            else
                                innerpath += "/"+allpaths[i - 1];
                            if (!manage.Exists(innerpath, allpaths[i]))
                            {
                                if (!create)
                                    return Result.NoneDirectory;
                                else
                                {                                if (!manage.CreateDirectory(innerpath, allpaths[i]))
                                        return Result.Systembusy;                            }
                            }
                        }
                    }
                }
                if (!manage.Exists(parentpath, dayPath))
                {
                    if (!create)
                        return Result.NoneDirectory;
                    else
                    {                    if (!manage.CreateDirectory(parentpath, dayPath))
                           // throw new ApplicationException("12");
                        return Result.Systembusy;
                    }
                }
                string fileName = string.Format("{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileName));
                string filePath = string.Format("{0}/{1}/{2}", parentpath, dayPath, fileName);
                if (!manage.UploadFile(filePath, this.PostedFile.InputStream))
                    return Result.Systembusy;
                else
                    _uploadfilepath = filePath;
                return Result.Success;
            }
        }}
      

  8.   

    使用如下:<%@ Register Namespace="YSMV.WEB"  TagPrefix="YsmvControl"%>
    <YsmvControl:UploadControl ID="UploadControl1" runat="server"/>小于500*500像素,512KB<asp:Label runat="server" ID="lbl_Msg" ForeColor="red"></asp:Label>
      

  9.   

                switch (UploadControl1.Save("Product/ProductPic", 512, true))
                {
                    case Result.ForbidExtension:
                        lbl_Msg.Text = "不允许的文件格式.";
                        break;
                    case Result.ForbidMime:
                        lbl_Msg.Text = "不允许的文件格类型.";
                        break;
                    case Result.InvalidSize:
                        lbl_Msg.Text = "上传文件太大..";
                        break;
                    case Result.NoneDirectory:
                        lbl_Msg.Text = "不存在该目录.";
                        break;
                    case Result.NoneFile:
                        goods.Pic = "";
                        break;
                    case Result.Success:
                        lbl_Msg.ForeColor = System.Drawing.Color.Green;
                        lbl_Msg.Text = "上传成功.";
                        goods.Pic = UploadControl1.Uploadfilepath;
                        break;
                    case Result.Systembusy:
                        lbl_Msg.Text = "系统繁忙,请稍候重试.";
                        break;
                    default:
                        lbl_Msg.Text = "未知错误.";
                        break;
      

  10.   

    using System;
    using System.Data;
    using System.Configuration;
    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;/// <summary>
    /// ResultEnum 的摘要说明
    /// </summary>
    namespace YSMV.WEB
    {
        public enum Result
        {
            NoneFile,
            ForbidExtension,
            ForbidMime,
            InvalidSize,
            NoneDirectory,
            Systembusy,
            Success
        }
    }少了一个 
    枚举类:
      

  11.   

    实在不好意思 太匆忙了 
    你先试试吧 
    很不错的是 url 的分页
      

  12.   

    下次 把 效果发到cnblogs 去好了 呵呵
      

  13.   

    使用的朋友 可以把  EnabledViewState  给false 了 
    效果不错 ,很快~
    汗...这里 就不要叫我浪客了吧
      

  14.   

    今天 回去整理下 
    大家多顶顶 明天给大家链接下载
    一共有三个控件 
    1是 数据控件 针对IList 的
    2 是 分页控件 Url 分页 效果不错de
    3是  FTP上传 控件  请高人指点这个  我还是在乎安全问题~
      

  15.   

    大家不好意思 上传控件少了配置文件 <add key="ImageAllowExt" value=".jpe|.jpeg|.jpg|.png|.tif|.tiff|.bmp|.gif"/>
    <add key="ImageMime" value="image/pjpeg|image/bmp|image/gif|image/png|image/jpeg|image/tiff"/>
      

  16.   

    大家顶下  刚才整理了以个  FTP上传那个 http://www.ysmv.com/upload.rar 控件
    数据控件那个还在整理中 谢谢大家了~~~~~
      

  17.   

    大家顶下  刚才整理了以个  FTP上传那个 http://www.ysmv.com/upload.rar 控件 
    数据控件那个还在整理中 谢谢大家了~~~~~
      

  18.   

    大家顶下  刚才整理了以个  FTP上传那个 http://www.ysmv.com/upload.rar 控件 
    数据控件那个还在整理中 谢谢大家了~~~~~
      

  19.   

    呵呵~`
    朋友们  帮我顶顶噢
    我已经整理好了上传控件的 地址在这里  http://www.ysmv.com/upload.rar数据控件的地址在:http://www.ysmv.com/DataControl.rar
      

  20.   

    呵呵~`
    朋友们  帮我顶顶噢
    我已经整理好了上传控件的 地址在这里  http://www.ysmv.com/upload.rar数据控件的地址在:http://www.ysmv.com/DataControl.rar有不清楚的地方 联系我就好了 
      

  21.   

    如果 要放在 工具栏里面 很简单  你们自己 csc :/library
    编译成类库 然后自己添加就好了的~~最近还在写其他很多控件 
    到时候全部 这样给大家看咯 其实本来是打算 直接发bll的 我已经签名了 算了 大家一起学习吧
    最近正在组织一个团队 做开源项目 
    有兴趣 可以联系 
    群:9778240
    或者我:83873308希望大家多交流 吧
    我也是个新手 还请高手们指教了~
      

  22.   

    汗...比我还凶
    ~
    这个控件的不好的地方就是
    分页的 ReBind 重新banding的
    如果还要处理回发事件 就有点问题 
    不过我在做一个可以处理回发的 url分页的控件
    还要解决url 重写的回发问题
      

  23.   

    上传控件的 地址在这里  http://www.ysmv.com/upload.rar 数据控件的地址在:http://www.ysmv.com/DataControl.rar 
      

  24.   

    实际 例子有的
    上传控件的 地址在这里  http://www.ysmv.com/upload.rar 数据控件的地址在:http://www.ysmv.com/DataControl.rar