开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜