![]() |
binding a value to a checkbox
Hello dotnet expert !!
I want to present as a checkbox the values -1 as true and 0 as false stored in a table. I got a Datalist and dragged a chekbok in the ItemTemplate section. I link my data field to it. I compile but at execution time, I got "Specified cast is not valid". Where can I associate the value -1 to true and 0 to false ? I did not find it in the properties. Thanks for your help!! Esperanza '================================================= ===== <TD><asp:CheckBox id=chkAutreSourceEnergie runat="serveur" Texte="Autre source energie" Checked='<# DataBinder.Eval(dataSet11, "Tables[Resultats].DefaultView.[0].Autre_Src_Energie")%>'> </asp:checkBox></TD> |
Re: binding a value to a checkbox
You need to do something like this:
CheckBoxItem.Checked = Convert.ToBoolean(value); that will convert your value(which is -1 or 0) to a boolean. "Esperanza" <esperanza222@hotmail.com> wrote in message news:%23fsmeaTEFHA.2156@TK2MSFTNGP10.phx.gbl... > Hello dotnet expert !! > I want to present as a checkbox the values -1 as true and 0 as false > stored > in a table. > I got a Datalist and dragged a chekbok in the ItemTemplate section. > I link my data field to it. I compile but at execution time, I got > "Specified cast is not valid". Where can I associate the value -1 to true > and 0 to false ? > I did not find it in the properties. > > Thanks for your help!! > Esperanza > > '================================================= ===== > > <TD><asp:CheckBox id=chkAutreSourceEnergie runat="serveur" Texte="Autre > source energie" Checked='<# DataBinder.Eval(dataSet11, > "Tables[Resultats].DefaultView.[0].Autre_Src_Energie")%>'> > </asp:checkBox></TD> > > |
| All times are GMT. The time now is 07:04 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.