ekberglinda
asked on
Modify Image column in DataGridView
Hi!
I use a mySQL database from which I populate a DataGridView in my C# .NET applicaiton.
One of the columns contains an image and I wonder if it is possible to modify the content of this column directly in the datagridview? Simply put, I want to select an image cell in the view and get the opportunity to add an image to it or delete an existing image. How do I modify the column (which is autogenerated) to enable this?
I use a mySQL database from which I populate a DataGridView in my C# .NET applicaiton.
One of the columns contains an image and I wonder if it is possible to modify the content of this column directly in the datagridview? Simply put, I want to select an image cell in the view and get the opportunity to add an image to it or delete an existing image. How do I modify the column (which is autogenerated) to enable this?
ASKER
It's a Windows application...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have no problem selecting the cell and gettings its value programmatically. What I request is a way to make the cell editable directly in the grid.
I believe that is what the code project link she gave you shows. Download the sample code and have a look.
ASKER
Sorry...missed the link!!! Will look at it and get back to you.
<asp:TemplateField HeaderText="Image">
<itemtemplate>
<asp:Image id="displayImage" runat="server" ImageUrl='<%# ((System.Data.DataRowView)
</itemtemplate>
<edititemtemplate>
<asp:FileUpload id="ImageUpload" runat="server" />
</edititemtemplate>
</asp:TemplateField>
I should warn you, this is going to be very complex because an image upload causes a postback and you're already in a postback state when you click to edit the row. So you're going to have to manually restore the edit state of the row.
Are you sure you want "in grid" editing of these records? From what I remember, it causes enormous viewstates and there's always something that it just won't do. Have you looked at the possibility of having a separate form to edit the records?