private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
seDS=subject.getSubject();
DropDownList1.DataSource=seDS;
DropDownList1.DataTextField="Subject_Name";
DropDownList1.DataValueField="Subject_Id";
this.DataBind();

int Question_Subject=Convert.ToInt32(DropDownList1.Items[0].Value);
mainDS=question.getQuestionBySubject(Question_Subject);
DataGrid1.DataSource=mainDS.Tables[0].DefaultView;
DataGrid1.DataBind();
}
} private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
seDS=subject.getSubject();
DropDownList1.DataSource=seDS;
DropDownList1.DataTextField="Subject_Name";
DropDownList1.DataValueField="Subject_Id";
this.DataBind();

int Question_Subject=Convert.ToInt32(DropDownList1.Items[DropDownList1.SelectedIndex].Value); mainDS=question.getQuestionBySubject(Question_Subject);
DataGrid1.DataSource=mainDS.Tables[0].DefaultView;
DataGrid1.DataBind();
}
}
页面展开出现DropDownList默认选择的考试题目  
我想根据DropDownList的选择的科目取得考试题目
但是在选择后没能改变  且还是原来信息

解决方案 »

  1.   

    http://www.google.com/search?hl=zh-CN&newwindow=1&q=asp.net+DropDownList+%E8%81%94%E5%8A%A8&lr=
      

  2.   

    你的DropDownList的AutoPostBack属性是否设置为True
      

  3.   

    你的DropDownList控件的AutoPostBack属性是否设置为true呢?你把下面这些代码去掉..在Page_Load中绑定后,在这里又重新绑定..所以你获取的ID值一直都是当前的ID值seDS=subject.getSubject();
    DropDownList1.DataSource=seDS;
    DropDownList1.DataTextField="Subject_Name";
    DropDownList1.DataValueField="Subject_Id";
    this.DataBind();
      

  4.   

    高手都来了,我是来253高手的。csdn有这些人真好。