Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - checkbox databind does not work

 
Thread Tools Search this Thread
Old 01-04-2005, 05:52 AM   #1
Default Re: checkbox databind does not work


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
  Reply With Quote
Old 01-04-2005, 08:55 AM   #2
=?Utf-8?B?UHJha2FzaC5ORVQ=?=
 
Posts: n/a
Default Re: checkbox databind does not work
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=?=
  Reply With Quote
Old 01-04-2005, 09:54 PM   #3
Ray Costanzo [MVP]
 
Posts: n/a
Default Re: checkbox databind does not work
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]
  Reply With Quote
Old 01-05-2005, 12:31 AM   #4
Jim
 
Posts: n/a
Default checkbox databind does not work
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:

<aspataGrid..>

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

</aspataGrid..>



fbool function:

public string fbool(int i)

{

if (i==1)

{

return "true";

}

else

{

return "false";

}

}



thanks



Jim




Jim
  Reply With Quote
Old 01-05-2005, 01:44 AM   #5
Jim
 
Posts: n/a
Default Re: checkbox databind does not work
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
  Reply With Quote
Old 01-05-2005, 04:42 AM   #6
Jim
 
Posts: n/a
Default Re: checkbox databind does not work
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46