Click here to Skip to main content
15,880,427 members
Articles / Web Development / ASP.NET

Handling Large Data Sets in Silverlight using WCF and Customized DataGrids

Rate me:
Please Sign up or sign in to vote.
4.57/5 (7 votes)
3 Jul 2010CPOL7 min read 62.6K   1.7K   34  
Display, edit and save large data sets in Silverlight using WCF based services and customized DataGrids
namespace MappingDataEditor.Web
{
    using System;
    using System.Text;
    using System.Web;
    using System.Web.Caching;

    /// <summary>
    /// Status of the Uploads
    /// </summary>
    public enum UploadState
    {
        Created,
        Uploading,
        Completed,
        Failed
    }

    public class UploadSession
    {
        private StringBuilder myStringData;

        /// <summary>
        /// Gets or sets (only private) the Handle of this Session - used as key in UploadSessions
        /// </summary>
        public Guid Handle
        {
            get;
            private set;
        }

        /// <summary>
        /// Gets or sets the table name (Custom data)
        /// </summary>
        public string Tablename
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets (only private) the state of the Upload
        /// </summary>
        public UploadState State
        {
            get;
            private set;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        internal UploadSession()
        {
            Handle = Guid.NewGuid();
            State = UploadState.Created;
            myStringData = new StringBuilder();
        }

        /// <summary>
        /// Gets the transfered data - use this when teh upload is done
        /// </summary>
        public string Contents
        {
            get
            {
                return myStringData.ToString();
            }
        }

        /// <summary>
        /// Adds one new block of data
        /// </summary>
        /// <param name="pNewData">Data that will be appended to the content</param>
        public void AddDataBlock(string pNewData)
        {
            State = UploadState.Uploading;
            myStringData.Append(pNewData);
        }

        /// <summary>
        /// Done!
        /// </summary>
        public void Close()
        {
            State = UploadState.Completed;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader maxment GmbH
Germany Germany
I wrote my first program more than 30 years ago when I was 8 years old. It was written in Pascal on an Apple ][e and calculated the Greatest Common Divisor. I was so proud when it finally work - from that day on computers where part of my life.

After successfully studying computer science I worked in a large cardiologic department as software developer. A few years later I went back to university and my PhD in medical computer science (Dr. sc. inf. biomed.). During this time a lead small team of really smart develeopers and we implemented the market leading cardiologic information system for the German market. In the following years I worked for Siemens but I missed this inspiring, creative athmosphere of a small company. So I changed back to a small start-up.

We are specialized on Webdevelopment and Windows technologies (C#, .Net, Silverlight, WPF, WCF, WinForms, Prism etc.). We are also experts in in Databases (ORACLE, MS-SQL-Server, PostgreSQL), medical standards (HL7, DICOM, IHE) and coordination of larger projects (including techniques like Agile Development and SCRUM). So if you are looking for a smart and efficient developer just contact me.

I started with C# and .NET in 2003. When Silverlight 2 hit the market I took a look at it and never let go again. Now - after two years and more than 500,000 lines of code - I think that I have a good theoretical and pratical understanding of this technology. So I would like to give back something to the community and share some tricks with you. I hope that it helps somebody - like all the interesting articles I read while learning the secrets of Silverlight, C#, .NET ...

Comments and Discussions