Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version
Go to top

COMET (or Reverse AJAX) based Grid Control for ASP.NET Web Applications - Scalable, High Performance and Low Latency Grid Control

, 1 Apr 2009
A COMET/Reverse Ajax based Web Grid Control, which can be used in ASP.NET web application. This control posts the updates to the client based on Server side event(s) thereby reducing network round trips.
GridControlCometAjax.zip
GridControlCometAjax
bin
Release
GridControlCometAjax.dll
GridControlCometAjax.pdb
GridControlCometAjax.zip
MultiMap.dll
MultiMap.pdb
Properties
Test
App_Data
bin
GridControlCometAjax.dll
MultiMap.dll
Test.dll
Test.pdb
GridCtrl
GridControlCometAjax.dll
GridControlCometAjax.zip
MultiMap.dll
Img
bg.JPG
Properties
TestGridControl.csproj.user
Perf.zip
Test.zip
GridControlCometAjax.dll
MultiMap.dll
Test.dll
Test.pdb
GridControlCometAjax.dll
GridControlCometAjax.zip
MultiMap.dll
bg.JPG
TestGridControl.csproj.user
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Drawing;

namespace Test
{
    public partial class _Default : System.Web.UI.Page
    {
        Thread thValue, thValue1;

        static Random randomNo = new Random();

        protected void Page_Load(object sender, EventArgs e)
        {
            GridControlCometAjax1.LoadControl(this);
            GridControlCometAjax2.LoadControl(this);
            this.Title = "Sample: COMET based GridControlCometAjax Custom Control.  This is ASP.Net based custom control.";
            thValue = new Thread(new ThreadStart(ThreadProc));

            thValue1 = new Thread(new ThreadStart(ThreadProc1));
            thValue1.Start();
            thValue.Start();
        }

        private void ThreadProc()
        {
            int RandSleep = 1000;
            int RowToModify = 2;
            int ColToModify = 2;
            double ValueToModify = 45.12;
            double PrevValueToModify = 45.12;

            int RowToModify1 = 2;
            int ColToModify1 = 4;
            double ValueToModify1 = 45.12;
            double PrevValueToModify1 = 45.12;

            for (int Rowitem = 0; Rowitem < 5; Rowitem++)
            {
                for (int ColItem = 0; ColItem < 5; ColItem++)
                {
                    ValueToModify = randomNo.NextDouble();
                    GridControlCometAjax1.DynModifyTableItem(Rowitem, ColItem, ValueToModify.ToString("N2"), false);
                    GridControlCometAjax1.DynModifyTableItemColor(Rowitem, ColItem, Color.Black, false);
                }
            }
            GridControlCometAjax1.DynUpdateAllClients();

            while (true)
            {
                Thread.Sleep(RandSleep);

                GridControlCometAjax1.DynModifyTableItem(RowToModify, ColToModify, ValueToModify.ToString("N2"), false);

                if (PrevValueToModify < ValueToModify)
                {
                    GridControlCometAjax1.DynModifyTableItemColor(RowToModify, ColToModify, Color.DarkGreen, false);
                }
                else
                {
                    GridControlCometAjax1.DynModifyTableItemColor(RowToModify, ColToModify, Color.Red, false);
                }

                GridControlCometAjax1.DynModifyTableItem(RowToModify1, ColToModify1, ValueToModify1.ToString("N2"), false);

                if (PrevValueToModify1 < ValueToModify1)
                {
                    GridControlCometAjax1.DynModifyTableItemColor(RowToModify1, ColToModify1, Color.DarkGreen, false);
                }
                else
                {
                    GridControlCometAjax1.DynModifyTableItemColor(RowToModify1, ColToModify1, Color.Red, false);
                }
                GridControlCometAjax1.DynUpdateAllClients();

                RandSleep = randomNo.Next(1800);
                RowToModify = randomNo.Next(5);
                ColToModify = randomNo.Next(5);
                PrevValueToModify1 = ValueToModify1 ;
                PrevValueToModify = ValueToModify;
                ValueToModify = randomNo.NextDouble() * 100.0;

                RowToModify1 = randomNo.Next(5);
                ColToModify1 = randomNo.Next(5);
                ValueToModify1 = randomNo.NextDouble() * 100.0;
            }

        }
        private void ThreadProc1()
        {
            int RandSleep = 1000;
            int RowToModify = 2;
            int ColToModify = 2;
            double ValueToModify = 45.12;
            double PrevValueToModify = 45.12;

            int RowToModify1 = 2;
            int ColToModify1 = 4;
            double ValueToModify1 = 45.12;
            double PrevValueToModify1 = 45.12;

            int RowToModify2 = 2;
            int ColToModify2 = 4;
            double ValueToModify2 = 45.12;
            double PrevValueToModify2 = 45.12;


            for (int Rowitem = 0; Rowitem < 5; Rowitem++)
            {
                for (int ColItem = 0; ColItem < 5; ColItem++)
                {
                    ValueToModify = randomNo.NextDouble();
                    GridControlCometAjax2.DynModifyTableItem(Rowitem, ColItem, ValueToModify.ToString("N2"), false);
                    GridControlCometAjax2.DynModifyTableItemColor(Rowitem, ColItem, Color.Black, false);
                }
            }
            GridControlCometAjax1.DynUpdateAllClients();

            while (true)
            {
                Thread.Sleep(RandSleep);

                GridControlCometAjax2.DynModifyTableItem(RowToModify, ColToModify, ValueToModify.ToString("N2"), false);

                if (PrevValueToModify < ValueToModify)
                {
                    GridControlCometAjax2.DynModifyTableItemColor(RowToModify, ColToModify, Color.DarkGreen, false);
                }
                else
                {
                    GridControlCometAjax2.DynModifyTableItemColor(RowToModify, ColToModify, Color.Red, false);
                }

                GridControlCometAjax2.DynModifyTableItem(RowToModify1, ColToModify1, ValueToModify1.ToString("N2"), false);

                if (PrevValueToModify1 < ValueToModify1)
                {
                    GridControlCometAjax2.DynModifyTableItemColor(RowToModify1, ColToModify1, Color.DarkGreen, false);
                }
                else
                {
                    GridControlCometAjax2.DynModifyTableItemColor(RowToModify1, ColToModify1, Color.Red, false);
                }

                GridControlCometAjax2.DynModifyTableItem(RowToModify2, ColToModify2, ValueToModify1.ToString("N2"), false);

                if (PrevValueToModify1 < ValueToModify1)
                {
                    GridControlCometAjax2.DynModifyTableItemColor(RowToModify2, ColToModify2, Color.DarkGreen, false);
                }
                else
                {
                    GridControlCometAjax2.DynModifyTableItemColor(RowToModify2, ColToModify2, Color.Red, false);
                }

                GridControlCometAjax2.DynUpdateAllClients();

                RandSleep = randomNo.Next(1500);
                RowToModify = randomNo.Next(5);
                ColToModify = randomNo.Next(5);
                PrevValueToModify1 = ValueToModify1;
                PrevValueToModify2 = ValueToModify2;
                PrevValueToModify = ValueToModify;
                ValueToModify = randomNo.NextDouble() * 100.0;

                RowToModify1 = randomNo.Next(5);
                ColToModify1 = randomNo.Next(5);
                ValueToModify1 = randomNo.NextDouble() * 100.0;

                RowToModify2 = randomNo.Next(5);
                ColToModify2 = randomNo.Next(5);
                ValueToModify2 = randomNo.NextDouble() * 100.0;

            }

        }
    }
}

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)

Share

About the Author

Bharath K A
Software Developer (Senior)
United States United States
No Biography provided

| Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 1 Apr 2009
Article Copyright 2009 by Bharath K A
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid