i want to display Emp Id from database to ListBox in c# web application.
but having no much idea with three tier i want to display record using three tier architecture.
i have used below code to do this. but there is no output.
how to fill ListBox using three tier architecture in c# web application?
DAL
public static DataTable fillListbox()
{
string conn = ConfigurationManager.ConnectionStrings["constring"].ConnectionString;
SqlConnection con = new SqlConnection(conn);
con.Open();
string sqlSelect = "SELECT EMP_ID From EMPLOYEE_MASTER";
SqlCommand cmd = new SqlCommand(sqlSelect, con);
SqlDataReader dr = cmd.ExecuteReader();
DataTable dtt = null;
if (dr.HasRows)
{
dtt = new DataTable("EMPLOYEE_MASTER");
dr.Read();
return dtt;
}
if (cmd != null)
{
con.Close();
cmd.Dispose();
cmd = null;
}
return dtt;
}
BAL
public static DataTable Get_EMPID()
{
return DAL.DAL.fillListbox();
}
PL
private void BindEMPID()
{
BAL.BAL empLstbox = new BAL.BAL();
DataTable dt = BAL.BAL.Get_EMPID();
empListbox.DataTextField = "EMP_ID";
empListbox.DataValueField = "EMP_ID";
empListbox.DataBind();
}