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 5 1373
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/
thanks Jason and btw the function has to return a bool.
ch Jim
"jasonkester" <ja*********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr 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/
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" <ja*********@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr 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/
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" <Pr********@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.com... 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" <ja*********@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr 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/
Fix your date.
--
Ray at work
Microsoft ASP/ASP.NET MVP
"Jim" <pe*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl... 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" <Pr********@discussions.microsoft.com> wrote in
message news:CD**********************************@microsof t.com... 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" <ja*********@gmail.com> wrote in message news:11**********************@z14g2000cwz.googlegr 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/ >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joe Bloggs |
last post by:
Anyone know why the code below does not work. All I want is to check a
checkbox, then hit a button, then for the value of the DataKeyField in
the DataGrid to show up as the Text property in a...
|
by: Thomas R |
last post by:
Is is possible?
In VS.NET 2003, Binding data to the repeater is easy, but when I try to add
an ASP:checkbox to the .aspx page, the designer won't recognize it, hence
the code view doesn't allow...
|
by: mike |
last post by:
Hi there:
I've read an excellent "how to"-article by Microsoft (no. 306227) - partly
cited cited at the end of this email).
I have implemented the code related to the part "How to Add a...
|
by: louise raisbeck |
last post by:
Hi there,
I am databinding a datagrid on the onload with the usual !IsPostBack
condition.
I have to create some dynamic checkboxes, because i dont know how many i
will need until the dataset...
|
by: louise raisbeck |
last post by:
Hi there,
I am databinding a datagrid on the onload with the usual !IsPostBack
condition.
I have to create some dynamic checkboxes, because i dont know how many i
will need until the dataset...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |