Solved

Setting ImageURL of GridView Template Field from c# code behind

Posted on 2009-05-04
3
907 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 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