我有一個DDL和我的aspx頁面中的ASP .NET網格視圖。我有兩個方法getALLProgram和getProgramBy名稱,兩者都工作正常。我的問題是:當頁面加載的第一次,我想打電話給getAllprogram方法,在這之後如果用戶選擇從DDL我想叫我getprogramByname方法的程序。如何以不同的條件加載相同的ASP網格視圖?
如何在這裏是我的代碼:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindProgramDDL();
BindGrid();
}
//BindProgramDDL();
}
protected void BindGrid()
{
string strProgramCode = DDLProgram.SelectedIndex.ToString();
List<FormGridEntity> gridEntities = new List<FormGridEntity>();
GridForResult.DataSource = gridEntities;
GridForResult.DataBind();
//throw new NotImplementedException();
}
protected void BindProgramDDL()
{
List<CcProgramEntity> programEntities = FormSaleSubmit_BAO.GetAllPrograms();
DDLProgram.DataSource = programEntities;
DDLProgram.DataTextField = "Shortname";
DDLProgram.DataValueField = "Id";
DDLProgram.DataBind();
string programCode = programEntities[DDLProgram.SelectedIndex].Code;
}
protected void OnDDLProgramChanged(object sender, EventArgs e)
{
List<CcProgramEntity> programEntities = FormSaleSubmit_BAO.GetAllPrograms();
string programCode = programEntities[DDLProgram.SelectedIndex].Code;
}
的代碼是不完整的。我仍在努力。但我沒有得到邏輯我怎麼能做到這一點,我已經告訴過你了。我希望我明確提出我的問題,如果它令人困惑,請讓我知道我應該在這裏提供什麼。
什麼是你的GridView的來源? SQLDataSource還是ObjectDataSource? –