views:

451

answers:

1

I want to store image into my datatable and while adding colum I want to set its default value, sending you code doing with checkboxes..

public void addCheckBoxesRuntime(){ for (int i = 0; i < InformationOne.Length; i++) { dt = new DataColumn(InformationOne[i][1] + " (" + InformationOne[i][0] + " )");

            dt.DataType = typeof(Boolean);

            viewDataTable.Columns.Add(dt);
            dt.DefaultValue = false;                
        }

}

+1  A: 

Make a DataColumn with type string and then store the string binary of the image into the field. Alternatively, use the binary itself with a byte[].

Should work 100%.

Something along the lines of this:

public string ImageConversion(System.Drawing.Image image)
{
    if (image == null) 
       return string.Empty;

    using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
    {
       image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Gif);

       string value = string.Empty;

       for (int intCnt = 0; intCnt <= memoryStream.ToArray.Length - 1; intCnt++) 
       {
           value = value + memoryStream.ToArray(intCnt) + ",";
       }

       return value;
    }
}
Kyle Rozendo