GridView\CheckBox [英] GridView\CheckBox
问题描述
我正在使用VS 2008.我有一个gridview,其中有几列是
复选框。每列的数据是1或0.当我尝试在浏览器中查看页面时,我收到一个错误指定的演员不是
有效。 。以下是该列的代码。 PL是
数据源中的字段名称。这是一个字符串字段。我确实将它更改为整数,但仍然收到了相同的错误消息。可能导致错误的原因是什么?
TIA
< asp:TemplateField>
< EditItemTemplate>
asp:CheckBox ID =" CheckBox1" RUNAT = QUOT;服务器" Checked =''<%#
Bind(" PL")%>''/>
< / EditItemTemplate>
< ItemTemplate>
< asp:CheckBox ID =" CheckBox1" RUNAT = QUOT;服务器" Checked =''<%#
Bind(" PL")%>''
Enabled =" false" />
< / ItemTemplate>
" gh" < gh@att.net在留言中写道
新闻:eT ************* @ TK2MSFTNGP02.phx.gbl ...
可能导致错误的原因是什么?
< asp:CheckBox / webcontrol的Checked标签需要填充
可以作为布尔值计算的东西。
如果你这样修改你的标记怎么办??
Checked =''<%#DataBinder.Eval(Container。 DataItem,PL)%>''
-
Mark Rae
ASP.NET MVP
http://www.markrae.net
Mark Rae [MVP]写道:
" gh" < gh@att.net在留言中写道
新闻:eT ************* @ TK2MSFTNGP02.phx.gbl ...
>可能导致错误的原因是什么?
< asp:CheckBox / webcontrol的Checked标签需要填充
,其中包含可以作为布尔值计算的内容。
如果你这样修改你的标记怎么办??
Checked =''<%#DataBinder.Eval(Container。 DataItem,PL)%>''
马克:
我也一样第26行的错误消息(System.InvalidCastException:指定
强制转换无效。
)。
< / EditItemTemplate> ;
第25行:< ItemTemplate>
第26行:< asp:CheckBox ID =" CheckBox1"
runat ="服务器" Checked =''<%#DataBinder.Eval(Container.DataItem," PL")%>''
第27行:启用=" false" />
第28行:< / ItemTemplate>
谢谢
" gh" ; < gh@att.net在留言中写道
新闻:OY ************** @ TK2MSFTNGP05.phx.gbl ...
>>可能导致错误的原因是什么?
< asp:CheckBox / webcontrol的Checked标签需要填充
,并且可以评估为布尔值。
如果您像这样修改标记会发生什么..?
Checked =''<%#DataBinder.Eval(Container.DataItem," PL")%>''
马克:
我得到相同的错误信息(System.InvalidCastException:指定演员
无效。)第26行。
< / EditItemTemplate>
第25行:< ItemTemplate>
第26行:< asp:CheckBox ID =" CheckBox1"
runat =" server" Checked =''<%#DataBinder.Eval(Container.DataItem," PL")%>''
第27行:启用=" false" />
第28行:< / ItemTemplate>
好的。什么*精确*是PL的值。在数据库之外,什么是数据类型?
为此,它需要是一个数据类型/值组合
可以转换为布尔值...
-
Mark Rae
ASP.NET MVP
http://www.markrae.net
I am using VS 2008. I have a gridview with several columns that are
checkboxes. The data for each column is either a 1 or 0. When I try to
view the page in the browser I get an error "Specified cast is not
valid". Below is the code for the column. PL is the field name in the
datasource. It is a string field. I did change it to integer and still
received the same error message. What could be causing the error?
TIA
<asp:TemplateField>
<EditItemTemplate>
asp:CheckBox ID="CheckBox1" runat="server" Checked=''<%#
Bind("PL") %>'' />
</EditItemTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" Checked=''<%#
Bind("PL") %>''
Enabled="false" />
</ItemTemplate>
"gh" <gh@att.netwrote in message
news:eT*************@TK2MSFTNGP02.phx.gbl...
What could be causing the error?The Checked tag of an <asp:CheckBox /webcontrol needs to be populated with
something that can be evaluated as a Boolean.
What happens if you modify your markup like so..?
Checked=''<%# DataBinder.Eval(Container.DataItem, "PL") %>''
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Mark Rae [MVP] wrote:"gh" <gh@att.netwrote in message
news:eT*************@TK2MSFTNGP02.phx.gbl...
>What could be causing the error?
The Checked tag of an <asp:CheckBox /webcontrol needs to be populated
with something that can be evaluated as a Boolean.
What happens if you modify your markup like so..?
Checked=''<%# DataBinder.Eval(Container.DataItem, "PL") %>''
Mark:
I get the same error message (System.InvalidCastException: Specified
cast is not valid.
) on Line 26.
</EditItemTemplate>
Line 25: <ItemTemplate>
Line 26: <asp:CheckBox ID="CheckBox1"
runat="server" Checked=''<%# DataBinder.Eval(Container.DataItem, "PL") %>''
Line 27: Enabled="false" />
Line 28: </ItemTemplate>
Thanks
"gh" <gh@att.netwrote in message
news:OY**************@TK2MSFTNGP05.phx.gbl...
>>What could be causing the error?
The Checked tag of an <asp:CheckBox /webcontrol needs to be populated
with something that can be evaluated as a Boolean.
What happens if you modify your markup like so..?
Checked=''<%# DataBinder.Eval(Container.DataItem, "PL") %>''
Mark:
I get the same error message (System.InvalidCastException: Specified cast
is not valid.) on Line 26.
</EditItemTemplate>
Line 25: <ItemTemplate>
Line 26: <asp:CheckBox ID="CheckBox1"
runat="server" Checked=''<%# DataBinder.Eval(Container.DataItem, "PL") %>''
Line 27: Enabled="false" />
Line 28: </ItemTemplate>OK. What *precisely* is the value of "PL" out of the database, and what is
the datatype?
For this to work, it will need to be a datatype / value combination which
can be converted into a Boolean...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
这篇关于GridView\CheckBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!