c# DataTable之增、删、查、改

添加:

代码
   
     
// 构建表
DataTable dt = new DataTable( " TempTable " );

// 构建列
DataColumn dc1 = new DataColumn( " ThumbnailURL " , Type.GetType( " System.String " )); // 缩略图路径
DataColumn dc2 = new DataColumn( " ThumbAlternateText " , Type.GetType( " System.String " )); // 替换文字
DataColumn dc3 = new DataColumn( " PictureShowURL " , Type.GetType( " System.String " )); // 图片路径
DataColumn dc4 = new DataColumn( " PicAlternateText " , Type.GetType( " System.String " )); // 替换文字
DataColumn dc5 = new DataColumn( " Title " , Type.GetType( " System.String " )); // 标题
DataColumn dc6 = new DataColumn( " Description " , Type.GetType( " System.String " )); // 图片描述
DataColumn dc7 = new DataColumn( " LinkURL " , Type.GetType( " System.String " )); // 链接
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Columns.Add(dc5);
dt.Columns.Add(dc6);
dt.Columns.Add(dc7);

// 构建行
for ( int i = 0 ; i < 4 ; i ++ )
{
DataRow dr
= dt.NewRow();
dr[
" ThumbnailURL " ] = " UserControl/ImgToggle/163Switcher/images/s " + i + " .jpg " ;
dr[
" ThumbAlternateText " ] = null ;
dr[
" PictureShowURL " ] = " UserControl/ImgToggle/163Switcher/images/ " + i + " .jpg " ;
dr[
" PicAlternateText " ] = null ;
dr[
" Title " ] = " 00 " ;
dr[
" Description " ] = " 00 " ;
dr[
" LinkURL " ] = " http://www.baidu.com " ;
dt.Rows.Add(dr);
}

 

你可能感兴趣的:(Datatable)