EnemyGateIsDown
Technical User
Hi guys,
I have a loop below that reads some fields from a table. The problem is I know the name of the field (from web.config) but I wont know its type, I just want to cast everything to a string. is there a method I can use that will cast the data to a string regardless of type (the bit in bold)?
Any help is as always greatly appreciated.
Chris
I have a loop below that reads some fields from a table. The problem is I know the name of the field (from web.config) but I wont know its type, I just want to cast everything to a string. is there a method I can use that will cast the data to a string regardless of type (the bit in bold)?
Any help is as always greatly appreciated.
Chris
Code:
SqlCommand cmd = new SqlCommand(VisitorSQL,dbCon);
SqlDataReader sdr = cmd.ExecuteReader();
.
.
.
while (sdr.Read())
{
//build the row
for (int dcol=1;dcol<12;dcol++)
{
field = ParseFieldEntry("ListField"+dcol,"Field");
if (field.Trim() != "")
{
int fieldnum = sdr.GetOrdinal(field);
[b]datacell.InnerText = sdr.GetString(fieldnum); [/b]
datarow.Cells.Add (datacell);
}
}
tblVisList.Rows.Add(datarow);
Viscount++;
}