June 2006 - Posts

I Love Scutt

Hi all,

I just wane say subscribe to this blog: http://weblogs.asp.net/scottgu/ (if you havent allready)
And some more information you really need to take a look at http://weblogs.asp.net/scottgu/archive/2006/05/08/445742.aspx it's web applications back a well it has been back for a while i'm just late blogging.

Happy netting!

Embedded Images in Html Follow Up

Hi all,
A while ago i wrote about embedded images and stuff and like it aint great for big files.
Well notting has changed for the but.
To give you a small idee on how to get some sort of a dynamic image out of object idee you might wane think about something like this:
Create a webpage.
Override the render with the one of the image you want to render.
Load the image using some query or post paramters the paramter you might wanne use are type (The fullname of the object), property (The property witch returns the image/bitmap) and a id with you may need for a DAO or something like that.
Use some reflection adn have fun.

Just a idee you might beable to use.
Happy netting!

O yeah you might also look at https://sourceforge.net/projects/ie7/ for some idee's.

Object to DataTable

Hi all, Did you ever had the problem that u just wanted your object in a datatable and didn't wane hardcode the datatable if so this may help:

#region ObjectArrayToDataTable
        internal static DataTable ObjectArrayToDataTable(object[] obj, Type type)
        {
            return ObjectArrayToDataTable(obj, type, null);
        }
        internal static DataTable ObjectArrayToDataTable(object[] obj, Type type, DataColumn[] extra)
        {
            DataTable dt = new DataTable();

            foreach (PropertyInfo pi in type.GetProperties())
            {
                if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime))
                {
                    dt.Columns.Add(pi.Name, pi.PropertyType);
                }
            }

            if (extra != null)
            {
                foreach (DataColumn c in extra)
                {
                    if (dt.Columns.Contains(c.ColumnName))
                        dt.Columns.Remove(c.ColumnName);
                    dt.Columns.Add(c);
                }
            }

            foreach (object k in obj)
            {
                DataRow dr = dt.NewRow();
                foreach (PropertyInfo pi in type.GetProperties())
                {
                    if (pi.PropertyType.IsPrimitive || pi.PropertyType == typeof(string) || pi.PropertyType == typeof(DateTime))
                    {
                        dr[pi.Name] = pi.GetValue(k, null);
                    }
                }
                dt.Rows.Add(dr);
            }

            return dt;
        }
        #endregion

I wish you all happy netting!