这是我用来绑定Movie DropDown的代码。在数据源中,我有两个数据用于绑定dropdown,movie dropdown在页面加载事件级别绑定,但抛出错误异常,如Image中所示:
public void BindMovie(string date)
{
try
{
MovieBAL objAccountBAL = new MovieBAL();
drpMovie.DataSource = objAccountBAL.GetMovieByDate(date).ToList();
drpMovie.ValueMember = "Id";
drpMovie.DisplayMember = "MovieName";
}
catch (Exception ex)
{
ELog.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}
答案 0 :(得分:1)
public void BindMovie(string date)
{
try
{
MovieBAL objAccountBAL = new MovieBAL();
drpMovie.ValueMember = "Id";
drpMovie.DisplayMember = "MovieName";
drpMovie.DataSource = bjAccountBAL.GetMovieByDate(date).ToList();
}
catch (Exception ex)
{
ELog.Write(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
System.Windows.Forms.MessageBox.Show(ex.Message);
}
}