使用List <t> </t>动态填充asp.net Gridview

时间:2012-07-19 18:46:00

标签: c# asp.net gridview

我有一个以List格式返回的Employee记录列表。如何动态填充gridview?

ePremiumSubscriber.Subscriber PremSubData = new ePremiumSubscriber.Subscriber();
List<ePremiumSubscriber.Subscriber> premSubList = new List<ePremiumSubscriber.Subscriber>();

ePremiumCustomerDAL.SearchPremSubscriberData(premSubList, sqlQuery);  


DataTable dtSearchResults = new DataTable();
dtSearchResults.Columns.Add("psLastName", System.Type.GetType("System.String"));
dtSearchResults.Columns.Add("psFirstName", System.Type.GetType("System.String"));

1 个答案:

答案 0 :(得分:2)

删除一个GridView控件你asp.net页面然后你可以按照他的方式去做

GridView1.DataSource = dtSearchResults ;

GridView1.DataBind();