指定的演员表在复选框中无效 [英] Specified cast is not valid in checkbox

查看:69
本文介绍了指定的演员表在复选框中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我在asp.net网络应用程序的详细信息视图表单中有一个复选框。表单数据源来自一个SQL表,该表具有一个名为Approved的列,该列绑定到Checkbox。我的问题是在运行时我得到错误Specified Cast无效。



有人可以解决这个问题吗?



提前致谢。



我尝试了什么:


$ Page $ Page $ Page $我试过

$ / $
foreach(DetailsViewRow DetailsViewRow in DetailsView1.Rows)

{

if(DetailsViewRow.Cells [Approved]。Value!= null&&(bool)DetailsViewRow.Cells [Approved]。超值)

{



}

else if(DetailsViewRow.Cells [Approved]。Value == null)

{



}

}

Hi there

I have a Checkbox in a Details View form in a asp.net web app. The form data source comes from a SQL table that has a column named Approved that is binded to the Checkbox. My problem is at runtime I get the error "Specified Cast is not valid".

Can someone give a solution to this issue?

Thanks in advance.

What I have tried:

on Page_Load Event I tried

foreach (DetailsViewRow DetailsViewRow in DetailsView1.Rows)
{
if (DetailsViewRow.Cells["Approved"].Value != null && (bool)DetailsViewRow.Cells["Approved"].Value)
{

}
else if (DetailsViewRow.Cells["Approved"].Value == null)
{

}
}

推荐答案

引用:

有人可以提供解决方案这个问题?

Can someone give a solution to this issue?

是的,你需要调试它。这个错误意味着你试图将某些东西投射到它不是的东西上。例如,字符串已批准为布尔值。我们无法运行您的代码,因此我们无法看到任何值。



您将首先找出错误所指向的代码行。然后,应该非常非常容易地弄清楚发生了什么。

Yes, you'll need to debug it. The error means you are trying to cast something into something it is not. For example, the string "approved" into a boolean. We cannot run your code so we cannot see what any of the values are.

You'll want to start with finding out which line of code the error is pointing to. Then it should be very, very easy to figure out what is happening.


参见表示和身份 - 编码中的神话般的冒险 [ ^ ]。


这篇关于指定的演员表在复选框中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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