When you create your TableViewSource class, pass in a reference to the TableViewController. Then in your RowSelected method use that reference to access the NavigationController of the TableViewController
On Thu, Jul 5, 2012 at 4:35 AM, proindigo <pro_ind...@live.com> wrote: > I am facing a new problem. Actually after showing the AssessmentID in a > alert > I also want the application to load a new screen AssessmentFacility. What I > have done is that I have created a new class inside my DataSOurce class > extending from UiViewControlller class. And in it I have written the code > block for navigating to the desired screen using PushViewController. But > the > application is throwing an error. Here is the code block for my entire > DataSource class. > > using System; > using System.Collections; > using System.Collections.Generic; > using System.Data; > using MonoTouch.UIKit; > using MonoTouch.Foundation; > using Mono.Data.Sqlite; > using ASTONAPP; > namespace ASTONAPP > { > public class BasicTableViewSource:UITableViewSource > > { > Navigator nvg=new Navigator(); > public BasicTableViewSource () > { > } > int AssessmentID; > protected List<BasicTableViewItemGroup> _tableItems; > string _cellIdentifier = "BasicTableViewCell"; > > public BasicTableViewSource (List<BasicTableViewItemGroup> > items) > { > this._tableItems = items; > } > > public override int NumberOfSections (UITableView > tableView) > { > return this._tableItems.Count; > } > > > public override int RowsInSection (UITableView tableview, > int section) > { > return this._tableItems[section].Items.Count; > } > > > public override string TitleForHeader (UITableView > tableView, int section) > { > return this._tableItems[section].Name; > } > > public override string TitleForFooter (UITableView > tableView, int section) > { > return this._tableItems[section].Footer; > } > > public override void RowSelected(UITableView tblview, > NSIndexPath > indexPath) > { > Navigator nvg=new Navigator(); > new UIAlertView("Notification", "You selected: > > "+this._tableItems[indexPath.Section].Items[indexPath.Row].ProjectName.ToString > ()+"", null, "OK", null).Show (); > > > AssessmentID=Convert.ToInt32(this._tableItems[indexPath.Section].Items[indexPath.Row].AssessmentID.ToString > ()); > new UIAlertView("Notification", "The Corresponding > AssessmentID Is: > "+AssessmentID+"", null, "OK", null).Show (); > nvg.NavigateToFacility (); > } > public override UITableViewCell GetCell (UITableView > tableView, > MonoTouch.Foundation.NSIndexPath indexPath) > { > //---- declare vars > UITableViewCell cell = > tableView.DequeueReusableCell > (this._cellIdentifier); > > //---- if there are no cells to reuse, create a > new one > if (cell == null) { > cell = new UITableViewCell > (UITableViewCellStyle.Subtitle, > this._cellIdentifier); > } > > //---- create a shortcut to our item > BasicTableViewItem item = this._tableItems > [indexPath.Section].Items > [indexPath.Row]; > > cell.TextLabel.Text = item.ProjectName; > cell.DetailTextLabel.Text = > item.AssessmentID.ToString (); > > return cell; > } > > > } > > public class Navigator:UIViewController > { > AssessmentFacility asfc; > public Navigator() > { > > } > > public void NavigateToFacility() > { > asfc=new AssessmentFacility(); > this.NavigationController.PushViewController > (asfc, true); <-------- this > line > } > } > > > } > > What am I doing wrong here? Can you spot any logical mistake? Is there any > alternate way to do this? > Please help me. > > Thanks. > > -- > View this message in context: > http://monotouch.2284126.n4.nabble.com/UITableView-Scenario-Help-Needed-tp4655680p4655765.html > Sent from the MonoTouch mailing list archive at Nabble.com. > _______________________________________________ > MonoTouch mailing list > MonoTouch@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/monotouch >
_______________________________________________ MonoTouch mailing list MonoTouch@lists.ximian.com http://lists.ximian.com/mailman/listinfo/monotouch