Solved

Datagridview image column

Posted on 2009-07-07
6
985 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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