dataraw虽然包含密钥但不包含密钥

时间:2014-03-31 05:37:49

标签: c# asp.net

这是我的代码:

现在我想将这些数据绑定到listview。

这是我的代码

var results = ZumaDa.GetCustomerInformation(CallerId);
                rowCount = results.Rows.Count;
                CallerId = rowCount > 0 ? results.Rows[0][4].ToString() : CallerId;
                if (rowCount > 1)
                {

                    ListView1.DataSource = new DataRow[] { results.Rows[0] };

                    ListView1.DataBind();

                }

我得到了这个例外

  

DataBinding:' System.Data.DataRow'不包含名称为' MembershipID'。

的媒体资源

1 个答案:

答案 0 :(得分:1)

尝试

ListView1.DataSource = results;

如果您只需要绑定一行,请尝试以下

ListView1.DataSource =results.AsEnumerable().Take(1).CopyToDataTable();