code is fine there is no error ,.,.
this code is working with all text boxes..
protected void Button2_Click(object sender, EventArgs e)
{
if (TextBox2.Text == "" && TextBox3.Text == "" && TextBox4.Text == "")
{
DateTime dt = Convert.ToDateTime(TextBox1.Text);
SqlCommand cmd = new SqlCommand("SELECT * FROM Transactions where report_type = @report_type and dateadd(dd, datediff(dd,0, [R_date]), 0) = @R_date ");
cmd.Connection = con;
cmd.Parameters.Add("@report_type", SqlDbType.NVarChar).Value = DropDownList1.SelectedValue;
cmd.Parameters.Add("@R_date", SqlDbType.DateTime).Value = dt.Date;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
else if (TextBox2.Text != "")
{
con.Open();
string s = ("Select * from Transactions where idcount like '%" + TextBox2.Text + "%' or Patient_ID_NO like '%" + TextBox2.Text + "%'or Patient_no like '%" + TextBox2.Text + "%'");
SqlCommand cmd = new SqlCommand(s, con);
cmd.Parameters.Add("@idcount", SqlDbType.Decimal).Value = TextBox2.Text;
cmd.Parameters.Add("@Patient_ID_NO", SqlDbType.Decimal).Value = TextBox2.Text;
cmd.Parameters.Add("@Patient_no", SqlDbType.Int).Value = TextBox2.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
TextBox2.Text = "";
}
else if (TextBox3.Text != "")
{
SqlCommand cmd = new SqlCommand("SELECT * FROM Transactions where Patient = @Patient ");
cmd.Connection = con;
cmd.Parameters.Add("@Patient", SqlDbType.NVarChar).Value = TextBox3.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
TextBox3.Text = "";
}
else
{
DateTime dt = Convert.ToDateTime(TextBox4.Text);
SqlCommand cmd = new SqlCommand("SELECT * FROM Transactions where dateadd(dd, datediff(dd,0, [R_date]), 0) = @R_date ");
cmd.Connection = con;
//cmd.Parameters.Add("@report_type", SqlDbType.NVarChar).Value = DropDownList1.SelectedValue;
cmd.Parameters.Add("@R_date", SqlDbType.DateTime).Value = dt.Date;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
TextBox4.Text = "";
}
Button3.Enabled = true;
}