473,382 Members | 1,359 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,382 software developers and data experts.

Images inside GridView

9
Hi,

can enybody help me please. I have a gridview with column that shows the images dynamically from database (see code below). What I need it to do is check to see if there is an image in each row to display it, and if there is not then display a standard image from directory. I think that is better solution than storing default images in each row in database where there is no image (users should be able to upload images). How can I do this?

Thanks.

<asp:datagrid id="myGrid" runat="server"
width="92%" cellpadding="5" font-size="8pt"
gridlines="horizontal"
headerstyle-backcolor="slategray"
headerstyle-forecolor="ivory"
headerstyle-font-bold="true"
ItemStyle-VerticalAlign="Top"
AutoGenerateColumns="false"
CellSpacing="5">

<columns>
<asp:templatecolumn>
<itemtemplate>
<a href='Home.aspx' >
<img alt="Click for details"
src="Handler.ashx?Image_Id=<%# Eval("Image_Id") %>" />
</a>
</itemtemplate>
</asp:templatecolumn>

<asp:boundcolumn headertext="Image_Id"
datafield="Image_Id" />
<asp:boundcolumn headertext="Image_Type"
datafield="Image_Type" />
</columns>
<ItemStyle VerticalAlign="Top" />
<HeaderStyle BackColor="SlateGray" Font-Bold="True" ForeColor="Ivory" />

</asp:datagrid>
Apr 24 '08 #1
1 1368
shweta123
692 Expert 512MB
Hi,

One method for doing this is put the default path in the table when no image is present for that record. So you do not need to check if Image exists or not in the .Net code.


Hi,

can enybody help me please. I have a gridview with column that shows the images dynamically from database (see code below). What I need it to do is check to see if there is an image in each row to display it, and if there is not then display a standard image from directory. I think that is better solution than storing default images in each row in database where there is no image (users should be able to upload images). How can I do this?

Thanks.

<asp:datagrid id="myGrid" runat="server"
width="92%" cellpadding="5" font-size="8pt"
gridlines="horizontal"
headerstyle-backcolor="slategray"
headerstyle-forecolor="ivory"
headerstyle-font-bold="true"
ItemStyle-VerticalAlign="Top"
AutoGenerateColumns="false"
CellSpacing="5">

<columns>
<asp:templatecolumn>
<itemtemplate>
<a href='Home.aspx' >
<img alt="Click for details"
src="Handler.ashx?Image_Id=<%# Eval("Image_Id") %>" />
</a>
</itemtemplate>
</asp:templatecolumn>

<asp:boundcolumn headertext="Image_Id"
datafield="Image_Id" />
<asp:boundcolumn headertext="Image_Type"
datafield="Image_Type" />
</columns>
<ItemStyle VerticalAlign="Top" />
<HeaderStyle BackColor="SlateGray" Font-Bold="True" ForeColor="Ivory" />

</asp:datagrid>
Apr 28 '08 #2

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

Similar topics

7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
3
by: CLEAR-RCIC | last post by:
I have several images i want to display in an ASP.Net application. The images are being passed to me in binary format from another application. Is there a good way to write them directly to an...
1
by: Nam | last post by:
I have a DropDownList control in a TemplateField inside my GridView How do I access this control’s SelectedIndexChanged event in codeBehind page? I don’t see the ID “DropDownList1” of...
7
by: =?Utf-8?B?cGF0cmlja2RyZA==?= | last post by:
Hi all! I have a gridview inside a datagrid (nested) for which (gridview) the rowcommand is not raised in order to delete a row from the grid! I also tried OnRowCommand="method", didn't work...
0
by: Samy | last post by:
Hi There, I am trying to display images in a gridview and display only valid images from the html in the database (and not display spacers, 1x1 pixel images etc). For this, I have a gridview...
1
by: HockeyFan | last post by:
protected void gvAuthorizedSigners_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EmptyInsert") { odsAuthorizedSigners.Insert(); return; } if (e.CommandName...
2
by: Paulo | last post by:
Hi, how are you ? Can you send me any examples about storing images on bd and showing them on gridview? Im using VS2005 asp.net 2.0 C# Thanks a lot!
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...
1
by: anasrazvi | last post by:
Hello All, I am implementing autocomplete functionality for a textbox inside a gridview. For this I am using a Div control to place the data based on the prefix key entered inside textbox. As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.