How to get the DataSourceId?
private SqlDataSource GetDataSource()
{
object o = Session["selectedDataSource"];
DataSourceType dsType = DataSourceType.Gtable;
if (o != null)
dsType = (DataSourceType)o;
switch (dsType)
{
case DataSourceType.tableT:
return DataSourceTID;
case DataSourceType.tableR:
return DataSourceRID;
case DataSourceType.tableC:
开发者_运维知识库 return DataSourceCID;
default:
return DataSourceCID;
}
}
For getting the datasourceid I wrote that code.But that gives the error as "Specified cast is not valid".This error is arise at dsType=(DataSourceType)
o line.
Please give me any suggextions.
Use enum parse method
http://msdn.microsoft.com/en-us/library/essfb559.aspx
DataSourceType dsType = (DataSourceType) Enum.Parse(typeof(DataSourceType), o);
精彩评论