Solved

Datagridview image column

Posted on 2009-07-07
6
977 Views
Last Modified: 2013-11-07
Hi,
I have a datagridview with imagecolumn.I need to change the image of the column as soon as the user selects the row.
Grid is populated by a datable.

Cheers
0
Comment
Question by:RIAS
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24793801
Where would this image come from? Do you have the path to the image in the datatable column?
0
 
LVL 16

Expert Comment

by:MikeMCSD
ID: 24793916
use Rowdatabound event, . . in C#, easy to convert to VB:

  protected void grid1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
   
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        Image img1 (Image)e.Row.FindControl("image1");

        if ((DataBinder.Eval(e.Row.DataItem, "img1")) = "your critera for the image"  )
        {
             img1.ImageUrl = "your new image"


0
 

Author Comment

by:RIAS
ID: 24794106
Hi,
Coud get till there.Can you guide me on how do I keep the datarow selected with a selected background color once clicked.

Cheers
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:RIAS
ID: 24794129
Hi,
Small editting on previous post.
datarow selected  ---> datarow highlighted
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24794301
Please explain in full details what you are trying to do. I think the code Mike posted is valid for ASP.NET and you are probably talking about WinForms application.
0
 
LVL 27

Accepted Solution

by:
VBRocks earned 500 total points
ID: 24794478
Take a look at this article, it's a great example of working with a DataGridView, and images, etc.

    http://www.codeproject.com/KB/grid/MergedDataGridViewControl.aspx

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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 shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
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…

820 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