Solved

Datagridview image column

Posted on 2009-07-07
6
962 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

22 Experts available now in Live!

Get 1:1 Help Now