Click here to Skip to main content
15,891,708 members
Articles / Programming Languages / C#

Databinding the SqlTypes

Rate me:
Please Sign up or sign in to vote.
4.70/5 (21 votes)
1 May 20032 min read 223.3K   3.7K   75  
Databinding the SqlTypes using the PropertyDescriptor class and the ITypedList Interface
using System;
using System.Data;

namespace ITypedListExample
{
	/// <summary>
	/// Summary description for FakeData.
	/// </summary>
	public class FakeData
	{
		private FakeData(){}

		public static MyCollection GetData()
		{
			MyCollection collection = new MyCollection();
			
			for ( int i = 0; i < 10; i++ )
			{
				MyCollection iCollection = new MyCollection();
				DataTable dt = GetDataTable();
				MyData ii = new MyData(dt.Rows[i]);
				
				
				ii.MyChildren = iCollection;
				collection.Add(ii);

				for ( int j = 0; j < 10; j++ )
				{
					MyCollection jCollection = new MyCollection();
					MyData jj = new MyData(dt.Rows[j]);
				
					jj.MyChildren = jCollection;
					iCollection.Add(jj);

					for ( int k = 0; k < 10; k++ )
					{
						MyCollection kCollection = new MyCollection();
						MyData kk = new MyData(dt.Rows[k]);
						jCollection.Add(kk);
					}
				}
			}
			return collection;
		}

		public static DataTable GetDataTable()
		{
			DataTable dt = new DataTable();

			dt.Columns.AddRange(new DataColumn[]{ new DataColumn("ID",typeof(int)), new DataColumn("dtStamp",typeof(DateTime)) } );

			for ( int j = 0; j < 10; j++ )
			{
				dt.Rows.Add(new object[]{j, DateTime.Now});
			}

			return dt;
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect support.com
Australia Australia

Comments and Discussions