datatable添加datacolumns\datarows

作者在 2007-04-19 17:47:00 发布以下内容
if(!Page.IsPostBack)
   {
    DataTable rblTable=new DataTable();
    rblTable.Columns.Add("CityName",System.Type.GetType("System.String"));
    rblTable.Columns.Add("CityNum",System.Type.GetType("System.Int32"));
    DataRow rblRow=rblTable.NewRow();
    rblRow["CityName"]="longkou";
    rblRow["CityNum"]=1;
    rblTable.Rows.Add(rblRow);
    this.RadioButtonList1.DataSource=rblTable;
    this.RadioButtonList1.DataTextField="CityName";
    this.RadioButtonList1.DataValueField="CityNum";
    this.RadioButtonList1.DataBind();
   }
ASP.NET | 阅读 1706 次
文章评论,共0条
游客请输入验证码
浏览77894次