The Datatablecommon class is primarily helpful in helping to extract values
List of methods:
public static string getcellstring (DataTable dt,int row, int column)
public static string getcellstring (DataTable dt,int Row, string columnName)
public static int Getcellint (DataTable dt, int row, int column)
public static int Getcellint (DataTable dt, int row, string columnName)
public static decimal Getcelldecimal (DataTable dt, int row, int column)
public static decimal Getcelldecimal (DataTable dt, int row,string columnName)
Public classDatatablecomon { Public Static stringGetcellstring (DataTable DT,intRowintcolumn) { stringstrvalue =string. Empty; Try { if(dt = =NULL|| Dt. Rows.Count = =0) return NULL; ObjectObjvalue=dt. Rows[row][column]; if(ObjValue = =NULL||convert.isdbnull (objvalue))return NULL; strvalue=objvalue.tostring (); } Catch(Exception) {}returnstrvalue; } Public Static stringGetcellstring (DataTable DT,intRowstringcolumnName) { stringstrvalue =string. Empty; Try { if(dt = =NULL|| Dt. Rows.Count = =0) return NULL; ObjectObjValue =dt. Rows[row][columnname]; if(ObjValue = =NULL||convert.isdbnull (objvalue))return NULL; strvalue=objvalue.tostring (); } Catch(Exception) {}returnstrvalue; } Public Static intGetcellint (DataTable DT,intRowintcolumn) { intIntvalue =0; Try { if(dt = =NULL|| Dt. Rows.Count = =0) return 0; ObjectObjValue =dt. Rows[row][column]; if(ObjValue = =NULL||convert.isdbnull (objvalue))return 0; Intvalue=Convert.ToInt32 (ObjValue); } Catch(Exception) {}returnIntvalue; } Public Static intGetcellint (DataTable DT,intRowstringcolumnName) { intIntvalue =0; Try { if(dt = =NULL|| Dt. Rows.Count = =0) return 0; ObjectObjValue =dt. Rows[row][columnname]; if(ObjValue = =NULL||convert.isdbnull (objvalue))return 0; Intvalue=Convert.ToInt32 (ObjValue); } Catch(Exception) {}returnIntvalue; } Public Static decimalGetcelldecimal (DataTable DT,intRowintcolumn) { decimalIntvalue =0; Try { if(dt = =NULL|| Dt. Rows.Count = =0) return 0; ObjectObjValue =dt. Rows[row][column]; if(ObjValue = =NULL||convert.isdbnull (objvalue))return 0; Intvalue=Convert.todecimal (ObjValue); } Catch(Exception) {}returnIntvalue; } Public Static decimalGetcelldecimal (DataTable DT,intRowstringcolumnName) { decimalIntvalue =0; Try { if(dt = =NULL|| Dt. Rows.Count = =0) return 0; ObjectObjValue =dt. Rows[row][columnname]; if(ObjValue = =NULL||convert.isdbnull (objvalue))return 0; Intvalue=Convert.todecimal (ObjValue); } Catch(Exception) {}returnIntvalue; } }
. NET DataTable Value helper classes