Inserting an Image into a Column

Discussion in 'ASP .Net Datagrid Control' started by W Akthar, Oct 5, 2004.

  1. W Akthar

    W Akthar Guest

    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 ????????
     
    W Akthar, Oct 5, 2004
    #1
    1. Advertising

  2. W Akthar

    Alex Homer Guest

    Alex Homer, Oct 5, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    10
    Views:
    2,669
    Alan Silver
    May 25, 2005
  2. Bhavesh
    Replies:
    0
    Views:
    437
    Bhavesh
    Jul 16, 2007
  3. Bhavesh
    Replies:
    5
    Views:
    653
    Bhavesh
    Jul 18, 2007
  4. Bhavesh
    Replies:
    1
    Views:
    460
    Bhavesh
    Jul 17, 2007
  5. Chauk-Mean Proum
    Replies:
    3
    Views:
    101
    Phrogz
    Jun 17, 2009
Loading...

Share This Page