Wil
I am using asp.net. How do you "catch the control in the datagrid after it's bound and remove it (or else the grid will display a broken link image)". That is what I have been trying with no luck.
thanks
tim
Main Topics
Browse All TopicsI need to place a thumbnail into a Datagrid's cell when the picture path exist in my database and place the text "N/A" when the picture path field is NULL in my database.
thanks
tim
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
Assuming that the ASPImage has an ID you could take care from code behind and set visible to true or false, depending on the given case ... like checking "If File Exists" before deciding if the image should be visible or not:
if (File.Exists(Server.MapPat
{
// ... Image Visible = True
}
else
{
// ... Image Visible = False
}
}
Best regards,
Raisor
yep, Raisor's plan works, or you could simply just clear the cell of the image control; I'd probably do it in the PreRender method of the datagrid:
private void DataGrid1_PreRender(object
{
foreach (DataGridItem itm in DataGrid1.Items)
{
Image img = (Image)itm.Cells[1].Contro
if (img.ImageUrl == null)
{
itm.Cells.Clear();
}
}
}
let me know if you have troubles.
wil
...oops, let's try that again :P.
private void DataGrid1_PreRender(object
{
foreach (DataGridItem itm in DataGrid1.Items)
{
Image img = (Image)itm.Cells[cell number that holds the image control].Controls[1];
if (img.ImageUrl == null)
{
itm.Cells[cell number that holds the image control].Controls.Clear();
}
}
}
wil
Hi,
@Headspace >>> ... do you mean you want to loop through all recordsets on render?
I'd rather think to check on a page to page basis which would be limited to the specified "records-to-display" amount ... the "if (File.Exists(Server.MapPat
Server.MapPath("images\no-
... instead of leaving image source leading to a non existing image!
Best regards,
Raisor
@Raisor: ...ummm, nope. I mean to iterate all of the rows in the datagrid after it has been databound, and either remove the empty image control before the grid is rendered, or (as in your example) set the image control to not visible. I'm not really sure how you thought i was looping through a dataset from my example, but i apologize if there was any confusion. I hope this clears it up : ).
wil
Business Accounts
Answer for Membership
by: HeadspacePosted on 2006-08-11 at 09:26:57ID: 17297443
...assuming that this is asp.net, you can use a template column in the datagrid to hold an asp image control, and bind the image to the data:
DataItem, "ImagePath")%> Runat=server ></asp:Image>
<asp:Image ImageUrl =<%# DataBinder.Eval(Container.
as for the "N/A", you'll either need to populate the database with a path to a custom "NA" thumbnail (rather than NULL, which would be the easiest), or catch the control in the datagrid after it's bound and remove it (or else the grid will display a broken link image).
wil