473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

GridView ImageField problem

Hi,

i have the below gridview code in my asp.net c# page. Problem is i having an error saying that "A field or property with the name 'ProfileID, Image' was not found on the selected data source.". This ProfileID and Image column is available in the database table. I not sure why the gridview can't find it.

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="gridview_myphoto" runat="server" AutoGenerateColumns="False" Width="100%">
  2.                     <Columns>
  3.                         <asp:ImageField HeaderText="Picture" DataImageUrlField="ProfileID, Image" DataImageUrlFormatString="Image/ProfileImage/{0}/{1}">
  4.                             <HeaderStyle Width="35px" />
  5.                         </asp:ImageField>
  6.                         <asp:TemplateField>
  7.                             <HeaderTemplate>
  8.                                 Caption
  9.                             </HeaderTemplate>
  10.                             <HeaderStyle Width="250px" />
  11.                             <ItemTemplate>
  12.                                 <asp:TextBox ID="txt_imgcaption" runat="server" Text='<%# Eval("Caption") %>' ></asp:TextBox>
  13.                             </ItemTemplate>
  14.                         </asp:TemplateField>
  15.                         <asp:TemplateField>
  16.                             <HeaderStyle Width="200px"/>
  17.                             <ItemStyle HorizontalAlign=Center />
  18.                             <ItemTemplate>
  19.                                 <asp:Button ID="but_setmainpage" runat="server" Text="Set Main Image" /><br />
  20.                                 <asp:Button ID="but_updcaption" runat="server" Text="Update Caption" /><br />
  21.                                 <asp:Button ID="but_remove" runat="server" Text="Remove" />
  22.                             </ItemTemplate>
  23.                         </asp:TemplateField>
  24.                     </Columns>
  25.                     <AlternatingRowStyle BackColor="#E0E0E0" />
  26.                 </asp:GridView>

// MY CODE-BEHIND FOR GRIDVIEW
Expand|Select|Wrap|Line Numbers
  1. protected void link_managemyphoto_Click(object sender, EventArgs e)
  2.         {
  3.             string myuserid = "1111";
  4.  
  5.             SqlConnection sqlconn2 = new SqlConnection("server=blabla;uid=sa;pwd=server;database=Profile");
  6.             sqlconn2.Open();
  7.  
  8.             SqlCommand sqlcomm2 = new SqlCommand();
  9.             sqlcomm2.Connection = sqlconn2;
  10.  
  11.             sqlcomm2.CommandText = "SELECT ProfileID, Image FROM MyImage WHERE ProfileID = @userid";
  12.             sqlcomm2.Parameters.AddWithValue("@userid", myuserid);
  13.  
  14.             SqlDataReader sqldatareader2 = sqlcomm2.ExecuteReader();          
  15.  
  16.             gridview_myphoto.DataSource = sqldatareader2;
  17.             gridview_myphoto.DataBind();
  18.  
  19.             sqldatareader2.Close();
  20.             sqlconn2.Close();
  21.         }
  22.     }
Please help.

Thx.
Aug 11 '08 #1
0 2260

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Benjamin | last post by:
Hi all, I am trying to manage two things on ASP .NET 2.0 with Venus, and I really don’t know how to do it In the gridview you have a ImageField column (with a resized image) which reacts...
9
by: J055 | last post by:
Hi I'm trying to get an instance of UserLists to persist after it's been used by the GridView. I understand from the documentation that The OnObjectCreated event allows access to the instance. I...
2
by: Dot Net Daddy | last post by:
Hello, As far as I know GridView is so flexible and I think it should be able to do this: I have a database containing URL for images. On the GridView I want to show all these images using...
1
by: The Colonel | last post by:
I'm using an ImageField in a GridView with the DataImageUrlField set to a URL on the 'Net. The images are not displaying (the URL is correct - I can copy and paste in the browser, they come right...
2
by: dixonjm | last post by:
I have quite a complicated problem with the above. I will do my best to explain, although I have a word doc (too large to attach here 149KB) with the problem explained full with screen shots if any...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
2
by: Raiders8180 | last post by:
Hi, I'm new to the community (1st post) so I hope I didn't leave anything out. I have a gridview (grdPics) created with 1 Imagefiled (picname) which contains the URL to where the image is stored. ...
0
by: =?Utf-8?B?RWR3YXJkSA==?= | last post by:
In Gridview I have column representing Thumbnail image which works fine.: <asp:ImageField DataImageUrlField="PicFile1" DataImageUrlFormatString="Images/A009/Thumbs/{0}"> </asp:ImageField> I...
3
by: anjali5 | last post by:
Hello Everyone, I want to display an image in my gridview. The only thing is my datatabse table is returning true if there is an image and false if there is no image and I am binding my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
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...

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.