473,787 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image field and sqldatasource

I need to display images in a SQL database using a gridview
I search some examples, what they did is very simple
add an image field, then set the folowing properties

<asp:imagefie ld dataimageurlfie ld="LastName"
dataimageurlfor matstring="~\Im ages\{0}.jpg"
alternatetext=" Employee Photo"
nulldisplaytext ="No image on file."
headertext="Pho to"
readonly="true"/>
<asp:boundfie ld datafield="Firs tName"
headertext="Fir st Name"/>
<asp:boundfie ld datafield="Last Name"
headertext="Las t Name"/>
if i set the datasource of the gridview to a sqldatasource with the
folowing commands
<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server"
ConflictDetecti on="CompareAllV alues"
ConnectionStrin g="<%$ ConnectionStrin gs:MyConnection String
%>"
SelectCommand=" SELECT [No_], [Picture], [Picture No_] AS Picture_No_
FROM [My Company$Item] ORDER BY [No_]

the 'Picture' is the image field, the Picture_No is used to identify
the picture, the No_ is the name of our product

and i have the following setting on my image field

<asp:ImageFie ld DataAlternateTe xtField="Pictur e_No_"
DataImageUrlFie ld="Picture_No_ "
HeaderText="Pic ture" DataImageUrlFor matString="~\Im age\{0}.gif">
</asp:ImageField>

i saw some example uses accessDataSourc e
but i think the image field should also work with sqldatasource
but when i render the gridview, the images are the Picture_No with red
cross

i am using the Visual Web Developer 2005 Express Edition in C#.Net

can someone point out what's wrong with my property settings?
especially regards to SQL Database Server

Mar 29 '06 #1
3 4145
I found that people are talking about the ImageUrl instead of the image
in the database

that is what stored in the database is the URL of the image instead of
the image itself

But I have no idea how an image is stored in a SQL server

Mar 29 '06 #2
A quick Google turns up this
http://www.dotnetbips.com/articles/d...le.aspx?id=101 as an
example of displaying images direct from the DB in a DataGrid.

I'd recommend that you store the image URL and not the image data
because you'll have less DB overhead, less mucking about with casting
to the image type, and life will generally be more pleasant.

Mar 29 '06 #3
thanks very much
I am using Visual Web Developer 2005 Express edition, which does not
have DataGrid control, instead it has GridView control
the GridView control doesnot have the ItemBound event
and all the events, no one is associated with an item,

the DataList control in VWD has the itemBound event, but C#.net have no
CType function
So is there a way I can do with GridView control, or DataList control
or some hints to declare and display a DataGrid object in codes?

Mar 29 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1480
by: Dave | last post by:
I have a sqldatasource on a form, sqldatasource1. I would like to reference this datasource and get the value of a field, like a=sqldatasource1.field.value which of course dosen't work. How can I get the value from the sqldatasource?
1
2640
by: aabruzzese | last post by:
Hi folks, Been struggling with this little puzzle. I am reading the MemberInfo table for the ClubStarterKit, the table includes the Avatar for the User. I would like to display the Avatar as an image in a databound element, in this case I am resorting to Gridview although I would prefer datalist or something simpler. <code>
4
29540
by: Dabbler | last post by:
I have two tables I'm editing in a Gridview. The VANS table contains a key to the other LESSOR table. I would like to use a dropdown list to select the LessorId value while displaying the Lessor table's "Company" field as text. When I commit the edit I get error:Must declare the scalar variable "@LessorId". Also as a bonus question ;) I don't know how to set the selectedindex value in the dropdown list based on the LessorId value in the...
4
6316
by: jens Jensen | last post by:
Hello, I have an image file name in a table that a let users modify via a GridView/DetailView pair. * The actual image file is saved in the image folder of the application. But the image is rendered in a templatefield 's <itemtemplate> on the detailsview. In the <edititemtemplate> i have a fileupload control . leting users upload a new picture and thus replace the old one.
3
2521
by: velu | last post by:
Asp.Net 2 I am trying to display Image from Northwind Database. I ran a queary "SELECT CategoryID, CategoryName, Description, Picture FROM Categories" but the Dataview displayes all the fields except Picture. so i add a Imagefield to display images..but now i get cross icon.. below is the code. correct me where i am wrong....
1
2737
by: Mike | last post by:
I'm using a SqlDataSource to fetch data and display it in a FormView. One of the elements is an image: <asp:Image ID="ImageFile" runat="server" ImageURL='<%# Eval("ImageFile", "~/storyimages/{0}") %>' /> However, sometimes there is no image to display, and therefore I want to set the Image control's Visible property to false. I tried evaluating whether the ImageFile field has a vlaue or not and using it to set the Visible property...
1
1295
by: TimmyTurner | last post by:
Hi all, I am trying to view an image from the database in the gridview control. I set up my SQLDatasource, and when testing the query i can see the images in the preview table, then i add a gridview control, add a new column, and select Image Field, and then my DataField, which is of type "Image". The problem is the only option i have is to select the "URL format string" and the "Image Data" option is not there, so the image does not...
1
10952
by: Ganesh | last post by:
Hi There, I've a page with with sqldatasource and detailsview, detailview was assinged to sqldatasource on design time. Now i would like to display a some fileds value in text box. How can i get the values from sqldatasource. Sqldatasource always returns one row only. I expect something like ths
4
2907
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data. I have read that when there is a null value in the database that there is no record in the "dataset". Can anyone show me how to bind a value in the...
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.