![]() |
Inserting an Image into a Column
Hi All,
I want to know how to insert an image into a datagrid column. I am using the following method to create a DataTabel which I then add to a dataset and finally set the datasource of datagrid to this dataset. DataSet dsOrgs = GetAllContactNotesByContactID(id); DataSet ds = new DataSet(); ds.Tables.Add(CreateDataTableContacts(dsOrgs)); DataView dv = new DataView(ds.Tables[0]); dataGridNotes.DataSource = dv; dataGridNotes.DataBind(); The method CreateDataTableContacts is as follows private DataTable CreateDataTableContacts(DataSet ds) { DataTable aTable = new DataTable("Organisations"); DataColumn dtCol; DataRow dtRow; DataRow dsRow; DataTable dsTable; dtCol = new DataColumn(); dtCol.DataType= System.Type.GetType ("System.String"); dtCol.ColumnName = "Name"; dtCol.Caption = "Name"; aTable.Columns.Add(dtCol); // **************************************** // **************************************** // How can I create this column into an imagecolumn ?? dtCol = new DataColumn(); dtCol.DataType= System.Type.GetType ("System.String"); dtCol.ColumnName = "Logo"; dtCol.Caption = "Logo"; aTable.Columns.Add(dtCol); // **************************************** // **************************************** dtCol = new DataColumn(); dtCol.DataType= System.Type.GetType ("System.String"); dtCol.ColumnName = "Status"; dtCol.Caption = "Status"; aTable.Columns.Add(dtCol); dsTable = ds.Tables[0]; for(int row=0; row < dsTable.Rows.Count; row++) { dsRow = dsTable.Rows[row]; dtRow = aTable.NewRow(); dtRow["Name"] = dsRow[2].ToString ().TrimEnd(); int logoID = Int32.Parse(dsRow[4].ToString ().TrimEnd()); // **************************************** // **************************************** switch { case 0: break; case 1: break; case 2: break; case 3: break; } // **************************************** // **************************************** int statusID = Int32.Parse(dsRow [3].ToString()); string status = GetStatusByStatusID (statusID); dtRow["Status"] = status.TrimEnd(); aTable.Rows.Add(dtRow); } return aTable; } Can anyone help please ???????? |
Re: Inserting an Image into a Column
If your data contains the URL of the image, you can use a HyperlinkColumn in
the declaration of the DataGrid. Turn off AutoGenerateColumns and specify a <Columns> section that contains the column types you want. You can use a BoundColumn for the columsn taht will display text. http://msdn.microsoft.com/library/de...classtopic.asp |
| All times are GMT. The time now is 12:12 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.