|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
saving object properties in sqlserverHi
Using vs2003 and sql server 2000 I would like ot save asp.net object attrributes such as alignment for a table cell, in sql server database. In my C# code I ahve to declare this as a HorizontalAlign type. then I give my variable the value "HorizontalAlign.Center". Now I can set the cell Horizontal align property to this variable. Is there way to save these special "types" in sql server, since I could not just appply the word "left" (for example) to the table cell Horizontal align attribute. Thanks jeff Jeff User wrote:
Show quote > Hi You can cast the enum value to an int, and save in the database. When > Using vs2003 and sql server 2000 > > I would like ot save asp.net object attrributes such as alignment for > a table cell, in sql server database. > In my C# code I ahve to declare this as a HorizontalAlign type. then I > give my variable the value "HorizontalAlign.Center". Now I can set the > cell Horizontal align property to this variable. > > Is there way to save these special "types" in sql server, since I > could not just appply the word "left" (for example) to the table cell > Horizontal align attribute. > > Thanks > jeff you read the int from the database, you can cast it back to the enum value. Example of casting: // you have an enum value: HorizontalAlign align = HorizontalAlign.Center; // cast it to an integer: int alignValue = (int)align; // cast it back to the enum value: HorizontalAlign align2 = (HorizontalAlign)alignValue; |
|||||||||||||||||||||||