Solved

Datagridview image column

Posted on 2009-07-07
6
976 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
DevOps Toolchain Recommendations

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

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 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