public Brand GetBrandById(int?id) { Brand brand = new Brand(); ; DataTable dt = _branddal.GetBrandById(id); foreach (DataRow dr in dt.Rows) { brand.id = Convert.ToInt32(dr["id"]); brand.name = string.IsNullOrEmpty(dr["name"].ToString()) ? "" : dr["name"].ToString(); } return(brand); }