469,964 Members | 1,683 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,964 developers. It's quick & easy.

How to display an icon in the gridview cell column dependent on another column

How can you display an icon the gridview cell column which is dependent on the text value of an adjacent column. Also, I setup the asp template,item and image controls, do i need to set the imgURL value in the asp control side? here's my code below:

Expand|Select|Wrap|Line Numbers
  1. protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
  2.         {
  3.             if (e.Row.RowType == DataControlRowType.DataRow)
  4.             {
  5.  
  6.                 Image Img1 = (Image)e.Row.FindControl("Img1");
  7.                 if (e.Row.Cells[7].Text == "Accepted")
  8.                 {
  9.                     Img1.ImageUrl = "~/images/check.ico";
  10.                     Img1.Visible=true;
  11.                 }
  12.                 if (e.Row.Cells[4].Text =="unack")
  13.                 {
  14.                     Img1.ImageUrl = "~/images/warning.ico";
  15.                     Img1.Visible = true;
  16.                 }  
  17.             }
May 19 '10 #1
2 2314
Frinavale
9,735 Expert Mod 8TB
What is wrong?
What you have here looks fine to me...
May 19 '10 #2
Frinavale
9,735 Expert Mod 8TB
Oh wait a sec I think I see.
Maybe you should be doing this in the OnRowBound event instead of the RowCreated event.
May 19 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Mike P | last post: by
10 posts views Thread by =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post: by
5 posts views Thread by =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.