binding a value to a checkbox

E

Esperanza

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>
 
S

Sean McKaharay

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top