Click here to Skip to main content
11,479,486 members (47,333 online)
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 285
1 Sergey Alexandrovich Kryukov 215
2 F-ES Sitecore 175
3 Richard MacCutchan 125
4 Frankie-C 104
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,441
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2015
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