how to write sp for the above and implement in .aspx page..
Need to get selected value from dropdownlist and textbox
need to get selected value from dropdownlist and textbox and than make the filter condition to pass value from code to stored procedure..

Pankaj PandeyRank #642 · 3.7K reputationPosted May 22, 2013, 4:45 AM EDT
It will better to read about sp_executesql and make query and use it .
thanks
Kumar SambhavRank #3,119 · 459 reputationPosted May 22, 2013, 5:00 AM EDT
{
MyMethod(Convert.ToInt32(ddlSearching.SelectedValue.ToString()), Convert.ToInt32(txtMySalary.Text.ToString()));
}
public void MyMethod(int DropDownloaValue, int TextBoxValue)
{
SqlConnection con = new SqlConnection("");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "sam_proc_MyProcedure";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.AddWithValue("@Selection_Type", 1);
cmd.Parameters.AddWithValue("@EmpType", DropDownloaValue);
cmd.Parameters.AddWithValue("@Salary", TextBoxValue);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet("MyTable");
da.Fill(ds, "MyTable");
gdvDailyReports.DataSource = ds;
gdvDailyReports.DataBind();
}
Stored Procedure
--=========================================================
-- CREATE BY :
-- CREATE DATE : <--/--/---->
-- MODIFY BY :
-- MODIFY DATE : <--/--/---->
-- DESCRIPTION :
--=========================================================
CREATE PROCEDURE sam_proc_MyProcedure
@Selection_TypeINT=0,
@EmpTypeINT=0,
@SalaryINT=0
AS
BEGIN
IF(@Selection_Type=1)
BEGIN
SELECT NAME, [ADDRESS] , MOBILE, PHONE FROM EmployeeMaster WHERE EmpType=@EmpType AND Salary <=@Salary
END
IF(@Selection_Type=2)
BEGIN
SELECT NAME, [ADDRESS] , MOBILE, PHONE FROM EmployeeMaster WHERE EmpType=@EmpType AND Salary >=@Salary
END
END
--=========================================================
Hope Your Problem Will Solve, Otherwise send me reply or Show me Your codding,
I'll try to solve your problem
parthiban karnanRank #2,548 · 548 reputationPosted May 22, 2013, 10:29 PM EDT
this code not working...
public void BindData()
Kumar SambhavRank #3,119 · 459 reputationPosted May 23, 2013, 2:11 AM EDT
cmd.Connection = con;
public void BindData()
{
SqlConnection con = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "sam_proc_MyProcedure";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Connection = con;
cmd.Parameters.Add(new SqlParameter("@roll", SqlDbType.VarChar)).Value = ddlDropDown.SelectedValue;
cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar)).Value = txtTextBox.Text;
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable("TableName");
da.Fill(dt);
con.Close();
gdvMyDetails.DataSource = dt;
gdvMyDetails.DataBind();
}