Ich erstelle eine App, bei der der Benutzer die Client-Informationen eingeben muss. Diese Informationen werden an die nächste Seite gesendet und in einem Tabellenformat angezeigt. Ich kann die Werte einfügen, aber nicht im Tabellenformat abrufen. Bitte helfen Sie.Xamarin IOS SQLite
private string pathtoDatabase;
public RoofExisting(IntPtr handle) : base(handle)
{
var documentFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
pathtoDatabase = Path.Combine(documentFolder, "ClientInfo_db.db");
using (var connection = new SQLiteConnection(pathtoDatabase))
{
var con = connection.Table<ClientInfo>();
foreach (var item in con)
{
ClientInfo Info = new ClientInfo(item.projectno, item.ClientName, item.CCompany, item.Caddress, item.CPostal, item.CPhonen, item.CEmail);
//Adding in the table view
CNinfo.Source = new TableSource(Info, this);
}
}
}
class TableSource:UITableViewSource
{
protected string[] tableItems;
protected String cellidentifier = "TableCell";
ViewController owner;
private ClientInfo info;
private RoofExisting roofExisting;
public TableSource(String[] items, ViewController owner)
{
tableItems = items;
this.owner = owner;
}
public TableSource(ClientInfo info, RoofExisting roofExisting)
{
this.info = info;
this.roofExisting = roofExisting;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return tableItems.Length;
}
public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
{
UIAlertController alertcontroller = UIAlertController.Create("Row Selected", tableItems[indexPath.Row], UIAlertControllerStyle.Alert);
alertcontroller.AddAction(UIAlertAction.Create("ok",UIAlertActionStyle.Default,null));
owner.PresentViewController(alertcontroller,true,null);
tableView.DeselectRow(indexPath,true);
}
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(cellidentifier);
if (cell == null)
cell = new UITableViewCell(UITableViewCellStyle.Default, cellidentifier);
cell.TextLabel.Text = tableItems[indexPath.Row];
return cell;
}
}