Hi.
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;
conn.Open();
trans = cmd.Connection.BeginTransaction();
try
{
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;
...
trans.Commit();
cmd.ExecuteScalar();
}
catch (SqlException se)
{
try
{
trans.Rollback();
}
catch { Page.Title = "SqlException :" + se.Message; }
try
{
trans.Rollback();
}
catch (Exception ex)
{
Page.Title = "Exception :" + ex.Message;
}
}
finally
{
try
{
conn.Close();
}
catch { }
}