There is a column called Student Image
in my Gridview control to display binary image from database. But I would like to allow users to insert & edit student image by using FileUpload control(upload image) in that column. So I do like this:
<asp:TemplateField HeaderText="Student Image">
<EditItemTemplate>
<asp:FileUpload ID="FileUpload1" runat="server" Text='<%# Eval("S_Image") %>'/>
</EditItemTemplate>
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="100px" Width="100px" ImageUrl='<%#"data:image/jpg;base64," + Convert.ToBase64String((byte[])Eval("S_Image")) %>' />
</ItemTemplate>
<FooterTemplate>
<asp:FileUpload ID="FileUpload2" runat="server" />
</FooterTemplate>
</asp:TemplateField>
I am able to display existing student image in database and display in GridView. But during insert/edit . There will be a problem [SqlException (0x80131904): Operand type clash: sql_variant is incompatible with image]
. How can I fix this?
User contributions licensed under CC BY-SA 3.0