![]() |
|
|
|||||||
![]() |
ASP Net - checkbox databind does not work |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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/ jasonkester |
|
|
|
|
#2 |
|
Posts: n/a
|
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 "Jim" wrote: > thanks Jason and btw the function has to return a bool. > > ch Jim > "jasonkester" <> wrote in message > news: oups.com... > > 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/ > > > > > =?Utf-8?B?UHJha2FzaC5ORVQ=?= |
|
|
|
#3 |
|
Posts: n/a
|
Fix your date.
-- Ray at work Microsoft ASP/ASP.NET MVP "Jim" <> wrote in message news:%... > 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 > > > "Prakash.NET" <> wrote in message > news:CD325044-9AA0-41A7-89A5-... > > 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 > > > > "Jim" wrote: > > > > > thanks Jason and btw the function has to return a bool. > > > > > > ch Jim > > > "jasonkester" <> wrote in message > > > news: oups.com... > > > > 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/ > > > > > > > > > > > > > > > Ray Costanzo [MVP] |
|
|
|
#4 |
|
Posts: n/a
|
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 <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 fbool function: public string fbool(int i) { if (i==1) { return "true"; } else { return "false"; } } thanks Jim Jim |
|
|
|
#5 |
|
Posts: n/a
|
thanks Jason and btw the function has to return a bool.
ch Jim "jasonkester" <> wrote in message news: oups.com... > 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/ > Jim |
|
|
|
#6 |
|
Posts: n/a
|
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 "Prakash.NET" <> wrote in message news:CD325044-9AA0-41A7-89A5-... > 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 > > "Jim" wrote: > > > thanks Jason and btw the function has to return a bool. > > > > ch Jim > > "jasonkester" <> wrote in message > > news: oups.com... > > > 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/ > > > > > > > > > Jim |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Any help for maintaining the work flow of the system………. | Zachar | Software | 1 | 08-04-2008 06:49 AM |
| Checkbox values problem in gridview | thanigaimani.thirumalai | Software | 0 | 11-09-2007 05:12 AM |
| Back button doesn't work when it is a secure page returning to a non secure page | Miss Mary | General Help Related Topics | 1 | 09-21-2007 10:32 AM |
| menu control doesn`t work on Studio 10 Plus | MZ | DVD Video | 0 | 03-05-2007 09:13 PM |
| Identity Theft at Work @ A True Review | Silverstrand | Front Page News | 0 | 06-27-2006 03:56 PM |