Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET ADO.NET
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>
 
Posted 29-Nov-12 1:28am
Edited 29-Nov-12 3:22am
v5

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

where you store image in database using http handler in binary format or in folder saving the path in database.
  Permalink  
Comments
prakash00060 at 29-Nov-12 8:37am
   
when i use handler then i have to use image id.
but i have to show image in behalf of some data.
please see the query.
this query is run on sql.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 195
3 DamithSL 195
4 Richard MacCutchan 178
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100