I want to display the image in the gridview template box. I want to know how to pass an image template for an Image control. This is what I am doing, ASPX Page:
<asp:GridView ID="GridView1" runat="server" Width="1000px" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False"> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Image ID="Image1" runat="server" Height="122px" ImageUrl="" Width="148px" /> <br /> </ItemTemplate> <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="300px" /> </asp:TemplateField></asp:GridView>
.CS Code:
public void show() { try { dt = g1.return_dt("select * from tbl_item_post where Ref_No is not null order by company"); if (dt.Rows.Count > 0) { pic1 = Convert.ToString(dt.Rows[0]["image_url"]); adsource = new PagedDataSource(); adsource.DataSource = dt.DefaultView; adsource.PageSize = 10; GridView1.DataSource = adsource; GridView1.DataBind(); } else { GridView1.DataSource = null; GridView1.DataBind(); } } catch (Exception ex) { ex.ToString(); } }
Please tell me how to do this.
source share