更新时间:2023-10-14 13:08:52
尝试在下拉列表中将autopostback设置为true
Try setting autopostback to true in your dropdownlist
public void Button2_Click(object sender, EventArgs e)
{
try
{
SqlDataAdapter da = new SqlDataAdapter("select pcode,fyyear,date,salary,ta,contigency,nrc,institcharges,others from monthly where pcode=(''" + DropDownList1.SelectedItem.ToString() + "'' ) AND fyyear=(''" + DropDownList2.SelectedItem.ToString() + "'')", con);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
DropDownList1.SelectedIndex = 0;
DropDownList2.SelectedIndex = 0;
}
catch (Exception ex)
{
ex.Message.ToString();
}
}