Ich habe UITableViewSource Ich möchte Schleife Daten aus Web-Service, den ich an Labels hinzugefügt UITableViewSourceIch benutze UITableViewSource möchte ich diesen Code ändern, um Schleife
Fisrt Label: Lblqut.text
Zweite Lable: LblAnswer.text
Ich möchte Daten in UITableViewSource in Etiketten anzeigen. Jetzt sind alle thins ok, aber ich bekomme Problem in dieser Linie employees.Add (item.Answ, item.AskID)
var employees = new List<Employee>
{
new Employee
{
Fullname="ahmed",
Department="Finance"
}
};
listVStud.Source = new EmployeesTVS(employees);
ich Problem in meinem Code
List<Employee> employees = new List<Employee>();
foreach (var item in e.Result)
{
employees.Add(item.Answ, item.AskID);
}
listVStud.Source = new EmployeesTVS(employees);
diese Klasse EmployeesTVS
class EmployeesTVS : UITableViewSource
{
List<Employee> employees;
public EmployeesTVS(List<Employee> employees)
{
this.employees = employees;
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
var cell = (EmployeeCell) tableView.DequeueReusableCell("Cell_id", indexPath);
var employee = employees[indexPath.Row];
cell.updatecell(employee);
return cell;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return employees.Count;
}
}
dieser Klasse Mitarbeiter
class Employee
{
public string Fullname
{
get;
set;
}
public string Department
{
get;
set;
}
diese Klasse EmployeeCell
public partial class EmployeeCell : UITableViewCell
{
public EmployeeCell (IntPtr handle) : base (handle)
{
}
internal void updatecell(Employee employee)
{
Lblqut.Text = employee.Fullname;
LblAnswer.Text = employee.Department;
}
}
Mitarbeiter eine Liste ist, haben keine Methode, wie Add (x, x); –