Solved

Setting ImageURL of GridView Template Field from c# code behind

Posted on 2009-05-04
3
899 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
  • 2
3 Comments
 
LVL 10

Expert Comment

by:cdebel
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:
cdebel 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

757 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now