Solved

Datagridview image column

Posted on 2009-07-07
6
969 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

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

Suggested Solutions

Title # Comments Views Activity
C# application error "Parameter Is Not Valid". 3 75
Tool Box 2 32
Want to create a userform that looks like the image provided 10 44
Not seen Link button 5 0
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
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.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now