Chuck Pinkert
Chuck Pinkert

Reputation: 1345

Getting to the ID of a UITableView Cell's Data object

So I have list of customer objects, custFname, CustLName, custID. Using LINQ I put all the first letters as sections in a RootView, and all the customers as StringElements inside of their respective section.

Now when an item is selected I can't find a way to get to the custID. I could add it as a value to the StringElement but I don't want it to appear on the screen. I can only find a reference to the RowIndex in the TableView, problem is, I'm using Monotouch.Dialogs search feature so the TableView items do not match my initial customer list so I can't just use the tableView index on the customer.

I know there is a tapped event handler that you can associate with a StringElement, but it is an NsAction only, which looks like it can't return anything or have anything passed in.

I'm new to the whole C#, Monotouch, Iphone world...Hopefully there is a really simple answer.

Upvotes: 0

Views: 478

Answers (1)

Chuck Pinkert
Chuck Pinkert

Reputation: 1345

Looks like it was as simple as adding a delegate to the tapped event:

//WHERE thisRow is a StringElement
thisRow.Tapped += delegate { LoadCustomer (customerID); };

Evidently that works, but just pointing Tapped to a method does not for whatever reason.

Upvotes: 2

Related Questions