//if your'e happy with a nullable type: int? _ManagerKey = ds.Tables[0].Rows[0]["ManagerKey"] as int?; //or maybe safer: int? _ManagerKey = (int?) ds.Tables[0].Rows[0]["ManagerKey"]; //If you want a default: int _ManagerKey = ds.Tables[0].Rows[0]["ManagerKey"] as int? ?? -1; //or, again, safer? int _ManagerKey = (int?) ds.Tables[0].Rows[0]["ManagerKey"] ?? -1;Adjust as neccessary for other types....
>public override void LoadData() >{ > DataSet ds = AppDataAccess.GetProjects(this.RecordId); > > if (ds != null && ds.Tables.Count > 0) > { > _ProjectKey = (int)ds.Tables[0].Rows[0]["ProjectKey"]; > _ClientKey = (int)ds.Tables[0].Rows[0]["ClientKey"]; > _ProjectTypeKey = (int)ds.Tables[0].Rows[0]["ProjectTypeKey"]; > _RateTypeKey = (int)ds.Tables[0].Rows[0]["RateTypeKey"]; > _ProjectStatusKey = (int)ds.Tables[0].Rows[0]["ProjectStatusKey"]; > _PriorityKey = (int)ds.Tables[0].Rows[0]["PriorityKey"]; > > if (ds.Tables[0].Rows[0]["ManagerKey"] != DBNull.Value) > { > _ManagerKey = (int)ds.Tables[0].Rows[0]["ManagerKey"]; > } > > _ProjectName = ds.Tables[0].Rows[0]["ProjectName"].ToString(); > _ProjectCode = ds.Tables[0].Rows[0]["ProjectCode"].ToString(); > _RateAmt = (float)ds.Tables[0].Rows[0]["RateAmt"]; > _EstHours = (float)ds.Tables[0].Rows[0]["EstHours"]; > _TotalHours = (float)ds.Tables[0].Rows[0]["TotalHours"]; > _EstStartDate = (DateTime)ds.Tables[0].Rows[0]["EstStartDate"]; > _EstEndDate = (DateTime)ds.Tables[0].Rows[0]["EstEndDate"]; > _ActualStartDate = (DateTime)ds.Tables[0].Rows[0]["ActualStartDate"]; > _ActualEndDate = (DateTime)ds.Tables[0].Rows[0]["ActualEndDate"]; > _PercentDone = (float)ds.Tables[0].Rows[0]["PercentDone"]; > _Comments = ds.Tables[0].Rows[0]["Comments"].ToString(); > _ProjectType = ds.Tables[0].Rows[0]["ProjectType"].ToString(); > _RateType = ds.Tables[0].Rows[0]["RateType"].ToString(); > _Status = ds.Tables[0].Rows[0]["Status"].ToString(); > _Priority = ds.Tables[0].Rows[0]["Priority"].ToString(); > _MgrFirstName = ds.Tables[0].Rows[0]["MgrFirstName"].ToString(); > _MgrLastName = ds.Tables[0].Rows[0]["MgrLastName"].ToString(); > > } >} >>