为什么图像在gridview中没有绑定? [英] why image is not binding in gridview?

查看:50
本文介绍了为什么图像在gridview中没有绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人知道吗?

为什么图像未在gridview中绑定?

来源:



Can anyone know?

why image is not binding in gridview?

source:

<asp:TemplateField HeaderText="Company Logo">
                    <ItemTemplate>
                   <asp:Image ID="clogo" runat="server" ImageUrl='<%#Bind("clogo") %>' />
                    </ItemTemplate>
                    </asp:TemplateField>


.cs代码:


.cs code:

public void load_grid()
   {

       SqlConnection cn = new SqlConnection(ConfigurationManager.AppSettings["constring"].ToString());
       SqlCommand cmd = new SqlCommand("select * from tbl_company1 where cstatus='Active'", cn);
       SqlDataAdapter da = new SqlDataAdapter(cmd);
       DataSet ds = new DataSet();
       da.Fill(ds);
       grdviewcompany.DataSource = ds;
       grdviewcompany.DataBind();
       cn.Close();
   }

推荐答案


您不能将图像直接绑定到gridview.因为图像将字节数组格式存储在数据库中.因此,我们需要使用HttpHandler转换为人类可见的格式,然后绑定到gridview.




问候,
荒谬
Hi,
You cant bind straightly image to gridview. Because image stored byte array format in database. so, we need to convert as human visible format using HttpHandler, then bind to gridview.




Regards,
anbukrish


这篇关于为什么图像在gridview中没有绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆