Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting ImageURL of GridView Template Field from c# code behind

Posted on 2009-05-04
3
Medium Priority
?
915 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: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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

972 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