Storing a DataRow into a Session (server) variable

I recently ran into a situation where I needed to store a DataRow object, which is not serializable, into a Session variable using the Session Server.  As I mentioned yesterday, all sessions should be stored to either the Session Server or the SQL Session Server.  This means that all of the objects being stored must be serializable.

My problem stemmed from the fact that a DataRow is not Serializable and there is no clean mechanism for it to become serializable.


However, a DataTable is serializable.  So, the simple solution is to:

  • Create a DataTable object
  • Add the DataRow to the Table
  • Store the DataTable in the Session variable.

To get the row out, you reverse the process.

  • Retrieve the DataTable from the Session object
  • Cast the object to a DataTable
  • Retrieve the first row from the table.

Other Related Items:

Building Secure Microsoft ASP.NET Applications (Pro-Developer)Building Secure Microsoft ASP.NET Applications (Pro-Developer)This guide presents a practical, scenario-driven approach to designing and building security-enhanced ASP.NET applications for Microsoft® Windows® 2000 and version 1.1 of the Microsoft .NET Framework.
Port Authority 44 (Secure In Band/Out of Band Management Terminal Server)Port Authority 44 (Secure In Band/Out of Band Management Terminal Server)Encrypted console port access to 4 host ports and 4 power reset ports over the network or dial-up regardless of the status of the network. This is a ... Read More >
Pond Skimmer NetPond Skimmer NetEG DANNER MFG - POND SKIMMER NETRoyal ID: ASP02134UPC: 025033021341Vendor: EG DANNER MFGTelescoping net designed for surface skimmingHeavy duty aluminum constructionTelescoping handle to 6.5"Soft, fish - safe nylon nettingSure-grip handle

Related Post

Comments are closed.

DotNetNuke Sponsor

 

Most Valuable Blogger
Sponsor