gridview databind上的无效强制转换异常 [英] Invalid cast Exception at gridview databind

查看:82
本文介绍了gridview databind上的无效强制转换异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var perDetail = from pd in cr.PersonalDetails
                            where pd.UserId ==(Guid)s
                            select pd;
            grvDisplay.DataSource = perDetail;
            grvDisplay.DataBind();
            grvDisplay.EditIndex = 0;

推荐答案

您可能想将LinqDataSource添加到您的网页,并将网格绑定到LinqDataSource.

然后,您像在代码中一样执行linq查询,并将LinqDataSource的DataSource属性设置为 perDetail

祝你好运,

爱德华(Eduard)
You may want to add a LinqDataSource to your webpage, and bind the grid to the LinqDataSource.

Then you perform your linq query like you do in your code, and set the DataSource property of the LinqDataSource to perDetail

Good Luck,

Eduard


我敢打赌,查询返回的数据集中的一个(或多个)字段为null ...
I bet one (or more) of the fields in the dataset returned by your query is null...


这篇关于gridview databind上的无效强制转换异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆