Click here to Skip to main content
15,040,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
m trying to display images in datagrid....

<img alt=""  runat="server" src='<%# "GetImage.aspx?ID=" (DataBinder.Eval(Container.DataItem, "Image"))  %>' ID="Img1"/>

cannot convert from type byte() to type integer()

any ideas??
Updated 28-Feb-13 5:05am
Sergey Alexandrovich Kryukov 28-Feb-13 11:07am
Ideas? What do you mean by ideas? :-)
Richard C Bishop 28-Feb-13 11:09am
I have lots of ideas. I want to start a business one day and fly a spaceship to Jupiter and invent free energy.
Sandeep Mewara 28-Feb-13 11:22am
Error and lines don't coincide. Some other code raising the issue.

1 solution

This is because there are not the types byte() or integer() in C#, and, in VB.NET, they can be the arrays of those integer values.

There are types byte, int and a lot more. "Conversion" you need is done by assignment. This is because the set of values if the type byte is a subset of that of the type int. You need type case to assign the value if int variable to byte variable.

As to arrays of different numeric types, they cannot be assigned compatible at all. Do I need to explain what would happen if such cast would be possible?

(I explained it in more general terms of sets of values, not ranges, because not all numeric types have ranges, floating-point types work differently and include Infinity and Not-a-Number values. Still, they have assignment compatibility rules. But integer types have ranges. "Range" is a bad, sloppy term which became a universally used computing jargon; correct term for set of values is "domain".)

Also, int and byte are actually alias names for System.Int32 and System.Byte. All numeric types have alias names, to make the code independent from the System namespace.

Please see:[^],[^],[^],[^].

See also this CodeProject article: Cheat Sheet - Casting in VB.NET and C#[^].

What to do? Review the types of variables you use in your ASP.NET construct.


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900