checkbox databind does not work

J

jasonkester

DataBinder.Eval will give you an object, not an int. You'll either
need to cast it or teach fbool to deal with it.

public string fbool(object o)
{
try
{
if ((int)o == 1)
return "true";
}
catch
{
// not an integer.
}
return "false";
}

Good luck!
Jason
Expat Software Consulting Services
http://www.expatsoftware.com/
 
G

Guest

Hi,

My idea is dont modify the function, instead try CInt() in the .aspx file.
i.e., CInt(DataBinder.Eval(......)).

Hope it helps.

Prakash.C
 
J

Jim

i am trying to bind a checkbox to a tablecolumn available (integer)

i get an error:

'The best overloaded method match for Company.Customers.fbool(int)' has some
invalid arguments'


datagrid:

<asp:DataGrid..>

<Columns>

<asp:TemplateColumn HeaderText="available">
<ItemTemplate>
<asp:CheckBox id="cbAvailable"
Checked='<%#fbool(DataBinder.Eval(Container, "DataItem.available"))%>'
Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>



<Columns>

</asp:DataGrid..>



fbool function:

public string fbool(int i)

{

if (i==1)

{

return "true";

}

else

{

return "false";

}

}



thanks



Jim
 
J

Jim

Hi
is this not a vbscript function? any way it does not work in this case, but
i got it solved (see previous posts)

ch JIm
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top