自定义datatable实例代码

public DataTable getzdydtsellout(int userid)
        {
            DataTable table = new DataTable();
            DataTable zdydt = null;
            table = gongyongdt();
            DataRow NewRow;
            zdydt = getesfselllistbyzjid(userid);
            for (int i = 0; i < zdydt.Rows.Count; i++)
            {
                NewRow = table.NewRow();
                NewRow["id"] = Convert.ToInt32(zdydt.Rows[i]["house_publishselloutid"].ToString());
                NewRow["type"] = "出售";
                NewRow["name"] = zdydt.Rows[i]["house_publish_house_subdistrict"].ToString();
                NewRow["address"] = zdydt.Rows[i]["house_publish_house_address"].ToString();
                NewRow["zone"] = zdydt.Rows[i]["house_publish_house_area"].ToString();
                NewRow["huxing"] = zdydt.Rows[i]["house_publish_house_room"].ToString() + "室" + zdydt.Rows[i]["house_publish_house_office"].ToString() + "厅" + zdydt.Rows[i]["house_publish_house_toilet"].ToString() + "卫" + zdydt.Rows[i]["house_publish_house_porch"].ToString() + "阳台";
                NewRow["usearea"] = zdydt.Rows[i]["house_publish_buildingarea"].ToString();
                NewRow["money"] = zdydt.Rows[i]["house_publish_sellmoney"].ToString() + "万";
                NewRow["publish_date"] = zdydt.Rows[i]["house_publish_date"].ToString();
                table.Rows.Add(NewRow);
            }
            DataView dv = table.DefaultView;
            dv.Sort = "publish_date Desc";
            table = dv.ToTable();
            return table;
        }
posted @ 2009-01-07 10:46  火精灵  阅读(362)  评论(0编辑  收藏  举报