using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
public partial class Contact : System.Web.UI.Page
{
SqlConnection connectioncontact = new SqlConnection(@"DATA SOURCE=xxxxx; Initial Catalog=xxxxx;User Id=xxxxx;Password=xxxxx;");
ListItem listitem = new ListItem(); //create new item class.
protected void Page_Load(object sender, EventArgs e)
{
try
{
connectioncontact.Open();
}
catch (Exception constat)
{
error_handler.Text = constat.ToString();
}
}
protected void afdelingen_Load(object sender, EventArgs e)
{
/* while (getdata.Read())
{
listitem.Text += "Test";
department.Items.Add(listitem);
}*/
try
{
SqlCommand getdepartment = new SqlCommand("SELECT * FROM contact_department", connectioncontact);
SqlDataReader getdata = getdepartment.ExecuteReader();
for (int i = 0; i <= 10; i++)
{
while (getdata.Read())
{
listitem.Text = "\n" + getdata["departmentID"];
department.Items.Add(listitem);
}
}
}
catch (Exception k)
{
error_handler.Text = k.ToString();
}
}
}