Solved

Setting ImageURL of GridView Template Field from c# code behind

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

948 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

23 Experts available now in Live!

Get 1:1 Help Now