绑定到gridview时出现错误数据源

时间:2013-01-02 12:21:27

标签: asp.net membership-provider

我有一个gridview,我正在尝试绑定数据:

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();

以上代码

如何将数据gridview绑定到ProviderUserKey,如字符串

1 个答案:

答案 0 :(得分:0)

GridView1.DataSource = Membership.GetAllUsers();
GridView1.DataBind();

必须工作:http://msdn.microsoft.com/en-us/library/dy8swhya.aspx

检查您的语法,最后没有“ s ”字母。

Membership.GetAllUsers s ();