tags:

views:

16

answers:

0

I am trying to bind a DataSet to a DataGridView. I dropped a DataGridView in a Winform. In the designer I set DataGridView to have a column with ColumnType DataGridViewLinkColumn.

The DataSet is bound to the DataGrid with this code

dataGridView1.DataSource = dataset;
dataGridView1.DataMember = "incidents";

The DataSet dataset is constructed like this:

dataset = new DataSet("incidents")
dataset.Tables.Add(CreateDataTable())

DataTable CreateDataTable()
{
    dataTable = new DataTable("incidents");
    DataRow dtRow;

    DataColumn dtCol = new DataColumn();
    dtCol.DataType = typeof(DataGridViewLinkCell) ;
    dtCol.ColumnName = "hyperlink";
    dtCol.ReadOnly = false;
    dtCol.Unique = false;
    dataTable.Columns.Add(dtCol);
return dataTable; 
}

Then I try to write to the DataSet like this:

dtRow = dataTable.NewRow();

DataGridViewLinkCell thisLink = new DataGridViewLinkCell();
thisLink.Value = "http://localhost"; 
dtRow["hyperlink"] = thisLink;

However when the data is displayed in the WinForm I was expecting "http://localhost" but i see "DataGridViewLinkCell { ColumnIndex=-1, RowIndex=-1 }"