How to use asp:ImageField in a GridView
-
Hi all, I'm using GridView with an ImageField column and somehow it doesn't display the pictures in my db. This is the code for adding new picture to the db (which I took from codeproject site)
if (!Page.IsValid) return; if (!FileUpload1.HasFile) return; try { int len = FileUpload1.PostedFile.ContentLength; byte[] pic = new byte[len]; FileUpload1.PostedFile.InputStream.Read(pic, 0, len); int glrId = int.Parse(_GallaryDropDownList.SelectedValue); _engine.AddPicture(gallrId, pic, _DescTextBox.Text); } catch {... }
The GridView markup is the following:<asp:GridView ID="GridView1" runat="server" ForeColor="Navy" Width="100%" AutoGenerateColumns="False" DataKeyNames="picID" DataSourceID="_PicturesSqlDataSource" Font-Names="Arial" Font-Size="11pt"> <Columns> <asp:BoundField DataField="picID" HeaderText="picID" InsertVisible="False" ReadOnly="True" SortExpression="picID" Visible="False" /> <asp:BoundField DataField="picGlrID" HeaderText="picGlrID" SortExpression="picGlrID" Visible="False" /> <asp:ImageField DataAlternateTextField="picDEscription" DataImageUrlField="picData" HeaderText="picture"> </asp:ImageField> <asp:BoundField DataField="picDEscription" HeaderText="description" SortExpression="picDEscription" /> <asp:TemplateField> <ItemTemplate> <asp:CheckBox ID="_SelForDelCheckBox" runat="server" /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
When I go to that page, I can see the rows but I cannot see the images, I can see the alt text instead.. Can you help me with that? What am I doing wrong? Thank you, Roy.