(转)c#中动态数组(arraylist )应用实例子(三层代码数据访问层,业务层,页面层)

用绑定一个 datalist 的三层代码说明一下:


dal 数据访问层代码:
------------------------------------------------------------
//绑定idlist,显示所有人员列表
  public dataset selectidlistall()
  {
string str = "select p_number,p_name from t_people";
dataset ds = new dataset();

mycon = new sqlconnection(dal.dalconfig.connectionstring);
try
{
  sqldataadapter mycomm = new sqldataadapter(str,mycon);
  mycomm.fill(ds,"t_people");   
   
  return ds;
}
catch(exception exc)
{
  throw exc;
}
  }


bll业务层代码:
----------------------------------------------------------------
//绑定idlist,显示所有人员列表
  public arraylist  selectidlistall()
  {
dal.tpeopledao peopledao = new tpeopledao();
dataset ds = new dataset();
ds = peopledao.selectidlistall();

// creates and initializes a new arraylist.
arraylist myal = new arraylist();
for(int i=0;i<ds.tables[0].rows.count;i++)
{
  myal.add(ds.tables[0].rows[i][0].tostring() + " " +ds.tables[0].rows[i][1].tostring() );     
}
return myal;
  }


页面层代码:
-----------------------------------------------------------------
//绑定idlist,显示所有人员列表
  private void selectidlistall()
  {
lab.bll.tpeoplebiz peoplebiz = new tpeoplebiz();
arraylist myal = peoplebiz.selectidlistall();
this.p_idlist.items.clear();

for(int i = 0 ;i<myal.count;i++)
{
  this.p_idlist.items.add(myal[i]);
}

  }



posted @ 2009-07-14 09:12  济阳补丁  阅读(467)  评论(0编辑  收藏  举报