Ref types in a datarow?

  • Thread starter Thread starter William Stacey [MVP]
  • Start date Start date
W

William Stacey [MVP]

Is there a way to get a ref to an object (say a instantiated class) in a
column of a datarow? Some other trick or workaround?
 
Hmm, not sure what you mean, but if you create the DataTable yourself, you
can specify the column type to be some custom type. For example:

DataTable dt=new DataTable();
dt.Columns.Add("thePoint",typeof(Point));
DataRow dr=dt.NewRow();
Point pt=new Point(5,5);
dr[0]=pt;
dt.Rows.Add(dr);

--
Teemu Keiski
MCP, Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

Email:
(e-mail address removed)
 
Thanks for the post, Teemu; excellent answer!

Steven Bras, MCSD
Microsoft Developer Support/Visual Basic WebData

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 
No problem.

Just note that for serializing to work (if you put DataTable with custom
type to DataSet) the type needs to be serializable as it normally would.

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

Email:
(e-mail address removed)


William Stacey said:
Thanks Teemu. Guess I just should have tried it, but the doco just showed
the native types
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003APR.1033/cpref/html/frlrfsystemdatadat
acolumnclassdatatypetopic.htm

Thanks again.

Teemu Keiski said:
Hmm, not sure what you mean, but if you create the DataTable yourself, you
can specify the column type to be some custom type. For example:

DataTable dt=new DataTable();
dt.Columns.Add("thePoint",typeof(Point));
DataRow dr=dt.NewRow();
Point pt=new Point(5,5);
dr[0]=pt;
dt.Rows.Add(dr);

--
Teemu Keiski
MCP, Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

Email:
(e-mail address removed)

William Stacey said:
Is there a way to get a ref to an object (say a instantiated class) in a
column of a datarow? Some other trick or workaround?
 
Back
Top