Hi, I'm a newbee to asp.net. I hope someone can help me.
I've created a BLL and DAL layer to get a country list out of my database.
In my asp page I have a dropdownlist where I would show the countries.
Asp page:
lstbCountry.DataSource =
Country_BLL.GetAllCountry();
lstbCountry.DataBind();
BLL
namespace
HelpdeskApplication
{
public class Country_BLL : Country_get_set
{
public Country_BLL()
{
}
public static List<Country_get_set> GetAllCountry()
{
List<Country_get_set> countryList = new List<Country_get_set>();
return countryList = Country_DAL.GetAll();
}
}
}
DAL
public static List<Country_get_set> GetAll()
{
SqlConnection cn = new SqlConnection(ConnectionString);
List<Country_get_set> CountryList = new List<Country_get_set>();
SqlCommand cmd = new SqlCommand();
try
{
cmd.Connection = cn;
cmd.CommandType =
CommandType.StoredProcedure;
cmd.CommandText =
"CountrySelectAllSorted_SP";
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Country_get_set country = new Country_get_set();
country.Id = (
int)dr["Id"];
country.Country = dr[
"country"].ToString();
CountryList.Add(country);
}
}
catch (Exception ex)
{
}
finally
{
cn.Close();
cmd.Parameters.Clear();
}
return CountryList;
}
get set class
this is the class where BLL and DAL inherit from
namespace
HelpdeskApplication
{
public class Country_get_set
{
private int id;
public int Id { get { return id; } set { id = value; } }
private string country;
public string Country { get { return country; } set { country = value; } }
}
}
I have 3 test countries in my database,
the result in the listbox is 3 times HelpDeskApplication.Country_get_set (namespace + file from inheritance.
Debug show me that the members Id and Country are one level lower then HelpDeskApplication.Country_get_set.
Hopes this is clear enough to understand
many thanks in advance