.cs下: public DataSet staff(string xueli) {SqlDataAdapter MyAdapter= new SqlDataAdapter();// Create Instance of Connection and Command Object SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["test"]); MyAdapter.SelectCommand = new SqlCommand("p_staff", myConnection);// Mark the Command as a SPROC MyAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;SqlParameter parameterxueli = new SqlParameter("@xueli", SqlDbType.VarChar, 6); parameterxueli.Value =xueli; MyAdapter.SelectCommand.Parameters.Add(parameterxueli); // Open the database connection and execute the command DataSet ds=new DataSet();
public DataSet staff(string xueli)
{SqlDataAdapter MyAdapter= new SqlDataAdapter();// Create Instance of Connection and Command Object
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["test"]);
MyAdapter.SelectCommand = new SqlCommand("p_staff", myConnection);// Mark the Command as a SPROC
MyAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;SqlParameter parameterxueli = new SqlParameter("@xueli", SqlDbType.VarChar, 6);
parameterxueli.Value =xueli;
MyAdapter.SelectCommand.Parameters.Add(parameterxueli);
// Open the database connection and execute the command
DataSet ds=new DataSet();
myConnection.Open();
try
{
MyAdapter.Fill(ds);
return ds;
}
finally
{
myConnection.Close();
}
}//endaspx下:
public void BindGrid(string sortfield)
{
LOVECsharp.p_staff myErp=new LOVECsharp.p_staff();
DataSet ds=myErp.staff(Ddl1.SelectedItem.Text.ToString());
DataView source = ds.Tables[0].DefaultView;
source.Sort=sortfield;
DataGrid1.DataSource=source;
DataGrid1.DataBind();
}
private void Btn_check_Click(object sender, System.EventArgs e)
{
DataGrid1.CurrentPageIndex=0;
BindGrid("工资");
}