Click here to Skip to main content
12,635,139 members (25,704 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL Server
this my form..i want to search database and display search result in another page in list view or data list.having no idea how to do this...
<table cellspacing="15" style="width:80%">
                    <td colspan="2" align="left">
                        <span style="font-size: small; font-family: Arial">Fields marked with 
                    <span style="color: #FF3300; font-size: small; font-family: Arial;">*</span><span>
                            style="font-size: small; font-family: Arial">

this is my database
create Table tbl_post_property_sale
	P_ID int identity(1,1)primary key,
	Property_Type varchar(50)not null,
	City_Id int references tbl_City(City_Id) not null,
	Locality_Id int references tbl_Locality(Locality_Id)not null,
	[Address] varchar(200)null,
	Pincode numeric null,
	Price varchar(20) not null,
	Bedrooms int null,
	Build_up_area varchar(20) not null,
	Key_Features varchar(200)null,
	Property_Image image not null,
	Name varchar(50)not null,
	Email varchar(50)not null,
	Mobile_No numeric not null  
Posted 29-Sep-12 22:35pm
Updated 29-Sep-12 22:39pm
Sandeep Mewara 30-Sep-12 3:44am
And the issue is?
raj rautela 30-Sep-12 4:03am
issue is m not having any idea how to write code for my search from and display search result in datalist or listview..

1 solution

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

Solution 1


i think you should first bind to database and then select it :

try this code in your pageload:

SqlConnection conn = new SqlConnection();
            SqlTransaction trans = null;
            conn.ConnectionString = ConfigurationManager.ConnectionStrings["Your ConnectionString name"].ConnectionString;
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            trans = cmd.Connection.BeginTransaction();
                cmd.CommandText = "selcet * from tbl_post_property_sale";
                cmd.Parameters.Add("@Property_Type  ", SqlDbType.VarChar).Value = textbox1.Text;
                cmd.Parameters.Add("@City_Id ", SqlDbType.NVarChar).Value = TextBox2.Text;
//try do the following for the rest of your Parameters in database
            catch (SqlException se)
                catch { Page.Title = "SqlException :" + se.Message; }
                catch (Exception ex)
                    Page.Title = "Exception :" + ex.Message;
                catch { }

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 30 Sep 2012
Copyright © CodeProject, 1999-2016
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