Solved

Setting ImageURL of GridView Template Field from c# code behind

Posted on 2009-05-04
3
913 Views
Last Modified: 2012-05-06
OKay so I have a gridview with a few columns in.
Want I want to to is to look at one of the hidden columns in the gridview (or object datasource) and evaluate its value and then set an image template field of that gridview depending upon the value of that column.

How would I do this?
0
Comment
Question by:andrewmilner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Expert Comment

by:Christian de Bellefeuille
ID: 24294390
Trap the RowDataBound of your GridView, then find your control in e.Row.

In VB.NET it would look like this... i'm sure you can translate to C#

    Private Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        e.Row.FindControl("").yourproperty = ....
    End Sub

Open in new window

0
 
LVL 10

Accepted Solution

by:
Christian de Bellefeuille earned 500 total points
ID: 24294417
I think in C# it should look like this:
((ImageButton) e.Row.FindControl("ImageButton1")).ImageUrl = "http://somesite.com/images/my_picture.jpg"

Open in new window

0
 

Author Comment

by:andrewmilner
ID: 24296554
Thanks that worked.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question