Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Inserting an Image into a Column

Reply
Thread Tools

Inserting an Image into a Column

 
 
W Akthar
Guest
Posts: n/a
 
      10-05-2004
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 ????????
 
Reply With Quote
 
 
 
 
Alex Homer
Guest
Posts: n/a
 
      10-05-2004
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting and inserting a "column" from/into an array Chauk-Mean Proum Ruby 3 06-17-2009 12:46 AM
Fetching & Inserting Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 5 07-18-2007 07:39 AM
Fetching & Inserting Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 1 07-17-2007 09:05 AM
Inserting & Fetching Data into a column of TEXT Data type in SQL server 2000 Using ASP.NET Bhavesh ASP .Net 0 07-16-2007 11:15 AM
Inserting into sql server using parameterized - get new column value ryan.mclean@gmail.com ASP .Net 10 05-25-2005 02:03 PM



Advertisments