CreateTable()

private void CreateTable()
  {
   DataSet ds=new DataSet();
   DataTable dt1=new DataTable();
              
   DataRow dr1 

   dt1.Columns.Add(new DataColumn("sText", typeof(string)));
   dt1.Columns.Add(new DataColumn("sValue",typeof(string)));

    
   dr1=dt1.NewRow();
   dr1["sText"]="1234";     
   dr1["sValue"]="jksdhfjk";

   dt1.Rows.Add(dr1);

 }

/////////////////////////////////////////////////////////////////////

int iCount=ds.Tables[0].Rows.Count;               
     ds.Tables[0].Columns.Add(new DataColumn("number", typeof(string)));                      
                   
     for(int i=0;i<iCount;i++)
     {      
        ds.Tables[0].Rows[i]["number"]=i+1;                       
     }

                    this.drpDel.DataSource = ds;
     this.drpDel.DataTextField = ds.Tables[0].Columns["number"].ToString();
     this.drpDel.DataValueField =ds.Tables[0].Columns["RC_ID"].ToString();
     this.drpDel.DataBind();

 

添加一列 并给该列下的每一个行赋予一个值。

posted on 2007-04-26 14:13  敌后武工队  阅读(154)  评论(0编辑  收藏  举报