</asp:DropDownList>
<HeaderStyle CssClass="Table_header" />
<Columns>
<asp:BoundField HeaderText="部门" DataField="depName">
<ItemStyle Width="30%"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="入职时间" DataField="Enter">
</Columns>
</asp:GridView>
SelectMethod="GetRecentEmpData2">
<SelectParameters>
<asp:Parameter Type="Int32" DefaultValue="0" Name="branchid"></asp:Parameter>
</SelectParameters>
</asp:ObjectDataSource>
{
get
{
return (new DepSystem()).GetBraTB();
}
}
protected void Page_Load(object sender, EventArgs e)
{
DropDownList2.DataBind();
DropDownList2.SelectedIndex = 0;
DropDownList2_SelectedIndexChanged(null, null);
}
protected void NewStaffView_DataBound(object sender, EventArgs e)
{
labNew.Text = NewStaffView.Rows.Count.ToString(); //统计
}
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
this.DataSourceNew.SelectParameters[0].DefaultValue = DropDownList2.SelectedValue; //这里就是传到方法中的参数
this.DataSourceNew.Select();
}
public DataSet GetRecentEmpData2(int branchid)
{
SqlCommand command = new SqlCommand();
command.CommandText = "GetRecentEmp2";
command.CommandType = CommandType.StoredProcedure;
command.Connection = con;
SqlParameter param = new SqlParameter("@iMonth", SqlDbType.Int);
param.Value = iMonth;
command.Parameters.Add(param);
param = new SqlParameter(paramChg("branchid"), SqlDbType.Int);
param.Value = branchid;
command.Parameters.Add(param);
commandAdp.SelectCommand = command;
DataSet data = new DataSet();
try
{
commandAdp.Fill(data);
}
catch (Exception ex)
{
throw new ApplicationException(ex.ToString());
}
con.Close();
return data;
}