单击搜索按钮(例如房地产网站)在数据列表中显示数据和图像.请帮助我为什么图像不显示在数据列表中? [英] display data and image in datalist on click of search button(like real estate website).Please help me why image is not show in datalist?

查看:78
本文介绍了单击搜索按钮(例如房地产网站)在数据列表中显示数据和图像.请帮助我为什么图像不显示在数据列表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

display data and image in datalist on click of  search button(like real estate website)
  protected void Page_Load(object sender, EventArgs e)
    {
        //lbl_msg.Text = Request.QueryString["name"].ToString();
        want = Request.QueryString["want"].ToString();
        bedroom=Convert.ToInt32(Request.QueryString["bedroom"]);
        city = Request.QueryString["city"].ToString();
        type=Request.QueryString["type"].ToString();
        budgetmin = Convert.ToInt32(Request.QueryString["budgetmin"]);
        budgetmax = Convert.ToInt32(Request.QueryString["budgetmax"]);
        location = Request.QueryString["location"].ToString();
        datalistsearchresult();

    }
    public void datalistsearchresult()
    {
        if (this.connopen() == true)
        {
            try
            {
                //query = ("select property_img,bedroom,pdiscription,contact_no,city,location,budget from residential where bedroom=" + bedroom + " and city='" + city + "' and budget between " + budgetmin + " and " + budgetmax + " and location='" + location + "'");
                //da = new SqlDataAdapter(query, connect);
                //ds = new DataSet();
                //da.Fill(ds, "residential");
                cmd = new SqlCommand("select property_img,bedroom,pdiscription,contact_no,city,location,budget from residential where bedroom=" + bedroom + " and city='" + city + "' and budget between " + budgetmin + " and " + budgetmax + " and location='" + location + "'",sqlconn);
                dr = cmd.ExecuteReader();
                if (dr.Read())
                {
                    byte[] imgData = (byte[])dr["property_img"];
                    Response.BinaryWrite(imgData);
                    

                }
                DataList1.DataSource = dr;
                DataList1.DataBind();
                connclose();
            }
            catch(Exception ex)
            {
                connclose();
            }
        }
    
    }
<asp:DataList ID="DataList1" runat="server">
    <ItemTemplate>
        <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("property_img")%>' Height="98px" Width="200px" />
        <asp:Label ID="Label1" runat="server" Text='<%#Eval("bedroom")%>'></asp:Label>
        <asp:Label ID="Label2" runat="server" Text='<%#Eval("pdiscription")%>'></asp:Label>
        <asp:Label ID="Label3" runat="server" Text='<%#Eval("city")%>'></asp:Label>
        <asp:Label ID="Label4" runat="server" Text='<%#Eval("location")%>'></asp:Label>
        <asp:Label ID="Label5" runat="server" Text='<%#Eval("budget")%>'></asp:Label>
        <asp:Label ID="Label6" runat="server" Text='<%#Eval("contact_no")%>'></asp:Label>
    </ItemTemplate>
    </asp:DataList>

推荐答案

,您可以使用http处理程序以二进制格式将图像存储在数据库中,也可以将其存储在文件夹中,并将路径保存在数据库中.
where you store image in database using http handler in binary format or in folder saving the path in database.


这篇关于单击搜索按钮(例如房地产网站)在数据列表中显示数据和图像.请帮助我为什么图像不显示在数据列表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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