Bit of a dummy couple of questions but im going to ask anyway.
If I have a class (well collection class of class objects) and they are instanciated by calling a DAL class which is instanciated on a page load event.
this works so far as I can bind a gridview to the collection.
When I do a postback I cannot seem to access the collection again i.e. when I use the selected index change event of the gridview I am wanting to lookup the selected item in the collection and return its object value.
Is this impossible or am I doing something wrong?
Second question if I select an object in the collection, is there a way to reference that object on another page or if not pass the object to another page?
Code:public partial class Outlines_usercontrols_CourseOutlines : System.Web.UI.UserControl { DAL_Outlines DALOutlines; string code; int OutlineID; public string Code { get { return code; } set { code = value; } } public int selectedOutline { get { return OutlineID; } set { OutlineID = value; } } protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack) { DALOutlines = new DAL_Outlines(); DALOutlines.Fill_Outlines(); ContentPlaceHolder BodyContent = (ContentPlaceHolder)Page.PreviousPage.Master.FindControl("maincontent"); ASP.usercontrols_courses_ascx test = (ASP.usercontrols_courses_ascx)BodyContent.FindControl("Courses1"); code = test.Code; this.lblCode.Text = code; this.GridView1.DataSource = DALOutlines.myOutlinesCollection; this.GridView1.DataBind(); this.FreeTextBox1.Text = DALOutlines.myOutlinesCollection.Item(0).Overview; } else { this.lblCode.Text = "Code Not Found"; } } } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { DataKey key; key = this.GridView1.SelectedDataKey; selectedOutline = (int)key.Value; this.FreeTextBox1.Text = DALOutlines.myOutlinesCollection.Item(selectedOutline).Overview; } }





Reply With Quote