项目3(WebDemo)中演示动态用指定程序集中getList的方法返回一个DataTable,用一个gridview显示其返回的数据。 调用演示 using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Reflection; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropBind(); } } 数据初始化,可配置在web.config文件中#region 数据初始化,可配置在web.config文件中 public void DropBind() { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("name")); dt.Columns.Add(new DataColumn("filepath")); DataRow dr = dt.NewRow(); dr["name"] = "加载自己定义数据"; dr["filepath"] = Server.MapPath(@"Files\Demo.dll"); dt.Rows.Add(dr); dr = dt.NewRow(); dr["name"] = "加载xml数据"; dr["filepath"] = Server.MapPath(@"Files\DemoXml.dll"); dt.Rows.Add(dr); this.DropDownList1.DataSource = dt; this.DropDownList1.DataTextField = "name"; this.DropDownList1.DataValueField = "filepath"; this.DropDownList1.DataBind(); } #endregion |