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>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)