fix Selected item in list box is null
from https://stackoverflow.com/questions/5859885/selected-item-in-list-box-is-null
It's because you are running
ListBox1.DataBind()
on every cycle. Change to:if (!IsPostBack)
{
var query = from emp in db.Employees
select emp.Employee_Name;
ListBox1.DataSource = query;
ListBox1.DataBind();
}
留言
張貼留言