2013-01-02 95 views
1

我有一個gridview,我試圖綁定數據:錯誤數據源時綁定到girdview

string id = Request.QueryString["uid"].ToString(); 

MembershipUser u = Membership.GetUser(new Guid(id)); 

GridView1.DataSource = Membership.GetUser(u.ProviderUserKey); 

GridView1.DataBind(); 

,我收到一個錯誤:

Data source is an invalid type. It must be either an IListSource, 
IEnumerable, or IDataSource. 

但我想:

GridView1.DataSource = Membership.GetAllUsers(); 

代碼高於ok

如何我可以通過ProviderUserKey像一個字符串數據綁定到gridview

+1

這是返回類型error.Don't使用它,因爲這僅包含對象的引用。相反,返回一個通用的List對象 – Niks

回答