processing postback

T

TS

i have a composite control that has dropdowns on them. The page will post
back on change, but their events won't raise. Can anyone tell me whats going
on? I tried to use the IPostBackDataHandler to try to get a hold of the
control to set values and such, but it has been no help. I'm confused at how
this control is supposed to work. I want it to be self contained so that
when a control changes, it posts back and then reloads its dependent drop
down lists with data that is filtered based on the value of the control that
changed.

Every time the page posts back to server, the it hits the init and load
events and createchildcontrols, but thats it. i can't get into the
XXX_SelectedIndexChanged events for some reason even though they are wired
to do so.

Any help will be appreaciated as i'm starting to feel dumb.

using System;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Text;

using Operations.Teams.Business;

using Operations.Teams.Data;

using Operations.Teams.Reporting;

using Operations.Teams.Reporting.WebControls;

namespace Operations.Teams.Web.ReportControls

{

/// <summary>

/// Summary description for FiscalAgentHierarchy.

/// </summary>

public class FiscalAgentHierarchy : Control, IReportParameterControl,
IPostBackDataHandler

{

public FiscalAgentHierarchy()

{

Parameters.Add(new Parameter("@SchoolYear"));

Parameters.Add(new Parameter("@ReportingGroup"));

Parameters.Add(new Parameter("@FiscalAgentID"));

Parameters.Add(new Parameter("@FundingSourceID"));

Parameters.Add(new Parameter("@ProviderID"));

Parameters.Add(new Parameter("@SiteID"));

Parameters.Add(new Parameter("@ClassID"));

Parameters["@SchoolYear"].Value = 2006;

}


#region Events


public bool LoadPostData(string postDataKey, NameValueCollection postData)

{

string postedValue = postData[postDataKey];

return true;

}

public void RaisePostDataChangedEvent()

{

rysReportingYearSelector_ReportingYearChanged(this, EventArgs.Empty);

}

protected override void LoadViewState(object savedState)

{

string zasdf="asdlfkjds";

}

protected override object SaveViewState()

{

string zsad="asdf";

}

protected override void OnInit(EventArgs e)

{

//this.EnsureChildControls();


// Do whatever the control usually does OnInit

base.OnInit(e);

}

protected override void OnLoad(EventArgs e)

{

//this.EnsureChildControls();

// Do whatever the control usually does OnInit

base.OnLoad(e);

}

private void rysReportingYearSelector_ReportingYearChanged(object sender,
EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void fasFiscalAgent_FiscalAgentChanged(object sender, EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void ddlProviders_SelectedIndexChanged(object sender, EventArgs e)

{

LoadSites();

}

private void ddlSites_SelectedIndexChanged(object sender, EventArgs e)

{

LoadClasses();

}

#endregion

protected override void CreateChildControls()

{

rysReportingYearSelector = new ReportingYearReportSelector();

fasFiscalAgent = new FiscalAgentReportSelector();

this.ddlFundingSource = new DropDownList();

this.ddlProviders = new DropDownList();

this.ddlSites = new DropDownList();

this.ddlClasses = new DropDownList();

rysReportingYearSelector.ID = ReportingYearSelectorControlId;

fasFiscalAgent.ID = FiscalAgentSelectorControlId;

ddlFundingSource.ID = FundingSourceControlId;

ddlProviders.ID = ProvidersControlId;

ddlSites.ID = SitesControlId;

ddlClasses.ID = ClassesControlId;

// Assign these controls' Page property because when they try to access Page
they get null reference - apparently they aren't in the control tree at that
point

rysReportingYearSelector.Page = this.Page;

fasFiscalAgent.Page = this.Page;

rysReportingYearSelector.ReportingYearChanged += new
EventHandler(rysReportingYearSelector_ReportingYearChanged);

fasFiscalAgent.FiscalAgentChanged += new
EventHandler(fasFiscalAgent_FiscalAgentChanged);

ddlProviders.SelectedIndexChanged += new
EventHandler(ddlProviders_SelectedIndexChanged);

ddlSites.SelectedIndexChanged += new
EventHandler(ddlSites_SelectedIndexChanged);

fasFiscalAgent.IsSubmitOnChange = true;

ddlProviders.AutoPostBack = true;

ddlSites.AutoPostBack = true;

// this.SchoolYear = rysReportingYearSelector.SchoolYear;

// check if can populate funding sources and providers (because fiscalAgent
has been saved in session)

if(this.fasFiscalAgent.SelectedFiscalAgentName != string.Empty)

{

LoadFundingSource();

LoadProviders();

}

else

{

ddlFundingSource.Visible = false;

ddlProviders.Visible = false;

}

// Initially set to false until their direct parent's selection has been
made (all other controls will have data on page load)

ddlSites.Visible = false;

ddlClasses.Visible = false;

// start containing table

this.Controls.Add(WebHelper.MakeLiteral("<table cellpadding=0
cellspacing=0><tr><td>"));


this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(rysReportingYearSelector);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(fasFiscalAgent);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Funding
Source</td><td>"));

this.Controls.Add(ddlFundingSource);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Providers</td><td>")
);

this.Controls.Add(ddlProviders);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Sites</td><td>"));

this.Controls.Add(ddlSites);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Classes</td><td>"));

this.Controls.Add(ddlClasses);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

// end containing table

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

}

private void LoadFundingSource()

{

int fiscalAgentId = this.fasFiscalAgent.SelectedFiscalAgentId;


if(fiscalAgentId != int.MinValue)

{

this.ddlFundingSource.Visible = true;

this.ddlFundingSource.DataSource = FiscalAgentFunding.Find(fiscalAgentId);

this.ddlFundingSource.DataTextField = "ShortDescription";

this.ddlFundingSource.DataValueField = "CodeId";

this.ddlFundingSource.DataBind();

if(this.ddlFundingSource.Items.Count > 1)

this.ddlFundingSource.Items.Insert(0, new ListItem(string.Empty,
string.Empty));

}

else

{

this.ddlFundingSource.Visible = false;

}

}

private void LoadProviders()

{

int fiscalAgentId = fasFiscalAgent.SelectedFiscalAgentId;

if(fiscalAgentId != int.MinValue)

{

ddlProviders.Visible = true;

ddlProviders.DataSource = FiscalAgentProvider.Find(fiscalAgentId,
rysReportingYearSelector.ReportingYearStartDate,
rysReportingYearSelector.ReportingYearEndDate);

ddlProviders.DataTextField = "ProviderName";

ddlProviders.DataValueField = "ProviderId";

ddlProviders.DataBind();

ddlProviders.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

this.ddlProviders.Items.Clear();

this.ddlProviders.Visible = false;

}

LoadSites();

}

private void LoadSites()

{

if(ddlProviders.SelectedValue != string.Empty)

{

// Load the Site search parameters.

SiteFindArgs siteFindArgs=new SiteFindArgs();

siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
tId);

ddlSites.Visible = true;

ddlSites.DataSource = Business.Site.Find(siteFindArgs);

ddlSites.DataTextField = "Name";

ddlSites.DataValueField = "SiteId";

ddlSites.DataBind();

ddlSites.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlSites.Items.Clear();

ddlSites.Visible = false;

}

LoadClasses();

}

private void LoadClasses()

{

if(ddlSites.SelectedValue != string.Empty)

{

ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();

adultEdClassFindArgs.FiscalAgentId =
Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);

adultEdClassFindArgs.ReportingYearStartDate =
rysReportingYearSelector.ReportingYearStartDate;

adultEdClassFindArgs.ReportingYearEndDate =
rysReportingYearSelector.ReportingYearEndDate;

adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;

adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;


ddlClasses.Visible = true;

ddlClasses.DataSource = Class.Find(classFindArgs);

ddlClasses.DataTextField = "Name";

ddlClasses.DataValueField = "ClassId";

ddlClasses.DataBind();

ddlClasses.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlClasses.Items.Clear();

ddlClasses.Visible = false;

}

}



#region Public Properties

#region IReportParameterControl Members

public object ParameterValue

{

get{ return null; }

set{ /*do nothing */ }

}

public ParameterCollection Parameters

{

get{ return parameters; }

set{ parameters = value;}

}

#endregion

public int SchoolYear

{

get{ return (int) ViewState["SchoolYear"]; }

set{ ViewState["SchoolYear"] = value; }

}

#endregion

#region Private Member Variables

private ReportingYearReportSelector rysReportingYearSelector;

private FiscalAgentReportSelector fasFiscalAgent;

private DropDownList ddlFundingSource;

private DropDownList ddlProviders;

private DropDownList ddlSites;

private DropDownList ddlClasses;

private ParameterCollection parameters = new ParameterCollection();

#endregion

#region Private Constants

private const string ReportingYearSelectorControlId =
"rysReportingYearSelector";

private const string FiscalAgentSelectorControlId =
"fasFiscalAgentSelector";

private const string FundingSourceControlId = "ddlFundingSource";

private const string FundingSourceLabelControlId = "lblFundingSource";

private const string ProvidersControlId = "ddlProviders";

private const string ProvidersLabelControlId = "lblProviders";

private const string SitesControlId = "ddlSites";

private const string SitesLabelControlId = "lblSites";

private const string ClassesControlId = "ddlClasses";

private const string ClassesLabelControlId = "lblClasses";

#endregion

}

}
 
T

TS

Well i know it has something to do with the CREATEChildControls method
because when i overrode render instead of doing that method at all, the
LoadPostData() was executed. I guess it has something to do with the
controls being recreated each time, I DON"T KNOW.

I need help all of you master coders :)


TS said:
i have a composite control that has dropdowns on them. The page will post
back on change, but their events won't raise. Can anyone tell me whats going
on? I tried to use the IPostBackDataHandler to try to get a hold of the
control to set values and such, but it has been no help. I'm confused at how
this control is supposed to work. I want it to be self contained so that
when a control changes, it posts back and then reloads its dependent drop
down lists with data that is filtered based on the value of the control that
changed.

Every time the page posts back to server, the it hits the init and load
events and createchildcontrols, but thats it. i can't get into the
XXX_SelectedIndexChanged events for some reason even though they are wired
to do so.

Any help will be appreaciated as i'm starting to feel dumb.

using System;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Text;

using Operations.Teams.Business;

using Operations.Teams.Data;

using Operations.Teams.Reporting;

using Operations.Teams.Reporting.WebControls;

namespace Operations.Teams.Web.ReportControls

{

/// <summary>

/// Summary description for FiscalAgentHierarchy.

/// </summary>

public class FiscalAgentHierarchy : Control, IReportParameterControl,
IPostBackDataHandler

{

public FiscalAgentHierarchy()

{

Parameters.Add(new Parameter("@SchoolYear"));

Parameters.Add(new Parameter("@ReportingGroup"));

Parameters.Add(new Parameter("@FiscalAgentID"));

Parameters.Add(new Parameter("@FundingSourceID"));

Parameters.Add(new Parameter("@ProviderID"));

Parameters.Add(new Parameter("@SiteID"));

Parameters.Add(new Parameter("@ClassID"));

Parameters["@SchoolYear"].Value = 2006;

}


#region Events


public bool LoadPostData(string postDataKey, NameValueCollection postData)

{

string postedValue = postData[postDataKey];

return true;

}

public void RaisePostDataChangedEvent()

{

rysReportingYearSelector_ReportingYearChanged(this, EventArgs.Empty);

}

protected override void LoadViewState(object savedState)

{

string zasdf="asdlfkjds";

}

protected override object SaveViewState()

{

string zsad="asdf";

}

protected override void OnInit(EventArgs e)

{

//this.EnsureChildControls();


// Do whatever the control usually does OnInit

base.OnInit(e);

}

protected override void OnLoad(EventArgs e)

{

//this.EnsureChildControls();

// Do whatever the control usually does OnInit

base.OnLoad(e);

}

private void rysReportingYearSelector_ReportingYearChanged(object sender,
EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void fasFiscalAgent_FiscalAgentChanged(object sender, EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void ddlProviders_SelectedIndexChanged(object sender, EventArgs e)

{

LoadSites();

}

private void ddlSites_SelectedIndexChanged(object sender, EventArgs e)

{

LoadClasses();

}

#endregion

protected override void CreateChildControls()

{

rysReportingYearSelector = new ReportingYearReportSelector();

fasFiscalAgent = new FiscalAgentReportSelector();

this.ddlFundingSource = new DropDownList();

this.ddlProviders = new DropDownList();

this.ddlSites = new DropDownList();

this.ddlClasses = new DropDownList();

rysReportingYearSelector.ID = ReportingYearSelectorControlId;

fasFiscalAgent.ID = FiscalAgentSelectorControlId;

ddlFundingSource.ID = FundingSourceControlId;

ddlProviders.ID = ProvidersControlId;

ddlSites.ID = SitesControlId;

ddlClasses.ID = ClassesControlId;

// Assign these controls' Page property because when they try to access Page
they get null reference - apparently they aren't in the control tree at that
point

rysReportingYearSelector.Page = this.Page;

fasFiscalAgent.Page = this.Page;

rysReportingYearSelector.ReportingYearChanged += new
EventHandler(rysReportingYearSelector_ReportingYearChanged);

fasFiscalAgent.FiscalAgentChanged += new
EventHandler(fasFiscalAgent_FiscalAgentChanged);

ddlProviders.SelectedIndexChanged += new
EventHandler(ddlProviders_SelectedIndexChanged);

ddlSites.SelectedIndexChanged += new
EventHandler(ddlSites_SelectedIndexChanged);

fasFiscalAgent.IsSubmitOnChange = true;

ddlProviders.AutoPostBack = true;

ddlSites.AutoPostBack = true;

// this.SchoolYear = rysReportingYearSelector.SchoolYear;

// check if can populate funding sources and providers (because fiscalAgent
has been saved in session)

if(this.fasFiscalAgent.SelectedFiscalAgentName != string.Empty)

{

LoadFundingSource();

LoadProviders();

}

else

{

ddlFundingSource.Visible = false;

ddlProviders.Visible = false;

}

// Initially set to false until their direct parent's selection has been
made (all other controls will have data on page load)

ddlSites.Visible = false;

ddlClasses.Visible = false;

// start containing table

this.Controls.Add(WebHelper.MakeLiteral("<table cellpadding=0
cellspacing=0><tr><td>"));


this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(rysReportingYearSelector);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(fasFiscalAgent);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Funding
Source</td><td>"));

this.Controls.Add(ddlFundingSource);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
this.Controls.Add(WebHelper.MakeLiteral( said:
);

this.Controls.Add(ddlProviders);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Sites</td><td>"));

this.Controls.Add(ddlSites);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
this.Controls.Add(WebHelper.MakeLiteral( said:
this.Controls.Add(ddlClasses);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

// end containing table

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

}

private void LoadFundingSource()

{

int fiscalAgentId = this.fasFiscalAgent.SelectedFiscalAgentId;


if(fiscalAgentId != int.MinValue)

{

this.ddlFundingSource.Visible = true;

this.ddlFundingSource.DataSource = FiscalAgentFunding.Find(fiscalAgentId);

this.ddlFundingSource.DataTextField = "ShortDescription";

this.ddlFundingSource.DataValueField = "CodeId";

this.ddlFundingSource.DataBind();

if(this.ddlFundingSource.Items.Count > 1)

this.ddlFundingSource.Items.Insert(0, new ListItem(string.Empty,
string.Empty));

}

else

{

this.ddlFundingSource.Visible = false;

}

}

private void LoadProviders()

{

int fiscalAgentId = fasFiscalAgent.SelectedFiscalAgentId;

if(fiscalAgentId != int.MinValue)

{

ddlProviders.Visible = true;

ddlProviders.DataSource = FiscalAgentProvider.Find(fiscalAgentId,
rysReportingYearSelector.ReportingYearStartDate,
rysReportingYearSelector.ReportingYearEndDate);

ddlProviders.DataTextField = "ProviderName";

ddlProviders.DataValueField = "ProviderId";

ddlProviders.DataBind();

ddlProviders.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

this.ddlProviders.Items.Clear();

this.ddlProviders.Visible = false;

}

LoadSites();

}

private void LoadSites()

{

if(ddlProviders.SelectedValue != string.Empty)

{

// Load the Site search parameters.

SiteFindArgs siteFindArgs=new SiteFindArgs();

siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
tId);

ddlSites.Visible = true;

ddlSites.DataSource = Business.Site.Find(siteFindArgs);

ddlSites.DataTextField = "Name";

ddlSites.DataValueField = "SiteId";

ddlSites.DataBind();

ddlSites.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlSites.Items.Clear();

ddlSites.Visible = false;

}

LoadClasses();

}

private void LoadClasses()

{

if(ddlSites.SelectedValue != string.Empty)

{

ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();

adultEdClassFindArgs.FiscalAgentId =
Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);

adultEdClassFindArgs.ReportingYearStartDate =
rysReportingYearSelector.ReportingYearStartDate;

adultEdClassFindArgs.ReportingYearEndDate =
rysReportingYearSelector.ReportingYearEndDate;

adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;

adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;


ddlClasses.Visible = true;

ddlClasses.DataSource = Class.Find(classFindArgs);

ddlClasses.DataTextField = "Name";

ddlClasses.DataValueField = "ClassId";

ddlClasses.DataBind();

ddlClasses.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlClasses.Items.Clear();

ddlClasses.Visible = false;

}

}



#region Public Properties

#region IReportParameterControl Members

public object ParameterValue

{

get{ return null; }

set{ /*do nothing */ }

}

public ParameterCollection Parameters

{

get{ return parameters; }

set{ parameters = value;}

}

#endregion

public int SchoolYear

{

get{ return (int) ViewState["SchoolYear"]; }

set{ ViewState["SchoolYear"] = value; }

}

#endregion

#region Private Member Variables

private ReportingYearReportSelector rysReportingYearSelector;

private FiscalAgentReportSelector fasFiscalAgent;

private DropDownList ddlFundingSource;

private DropDownList ddlProviders;

private DropDownList ddlSites;

private DropDownList ddlClasses;

private ParameterCollection parameters = new ParameterCollection();

#endregion

#region Private Constants

private const string ReportingYearSelectorControlId =
"rysReportingYearSelector";

private const string FiscalAgentSelectorControlId =
"fasFiscalAgentSelector";

private const string FundingSourceControlId = "ddlFundingSource";

private const string FundingSourceLabelControlId = "lblFundingSource";

private const string ProvidersControlId = "ddlProviders";

private const string ProvidersLabelControlId = "lblProviders";

private const string SitesControlId = "ddlSites";

private const string SitesLabelControlId = "lblSites";

private const string ClassesControlId = "ddlClasses";

private const string ClassesLabelControlId = "lblClasses";

#endregion

}

}
 
T

TS

i followed the article at:
http://msdn.microsoft.com/library/d...de/html/cpconpostbackdataprocessingsample.asp
and it works like that except like i said when I use createchildControls
instead of render (because i need to render multiple controls), it doesn't
hit those postback methods.

thanks again

TS said:
Well i know it has something to do with the CREATEChildControls method
because when i overrode render instead of doing that method at all, the
LoadPostData() was executed. I guess it has something to do with the
controls being recreated each time, I DON"T KNOW.

I need help all of you master coders :)


TS said:
i have a composite control that has dropdowns on them. The page will post
back on change, but their events won't raise. Can anyone tell me whats going
on? I tried to use the IPostBackDataHandler to try to get a hold of the
control to set values and such, but it has been no help. I'm confused at how
this control is supposed to work. I want it to be self contained so that
when a control changes, it posts back and then reloads its dependent drop
down lists with data that is filtered based on the value of the control that
changed.

Every time the page posts back to server, the it hits the init and load
events and createchildcontrols, but thats it. i can't get into the
XXX_SelectedIndexChanged events for some reason even though they are wired
to do so.

Any help will be appreaciated as i'm starting to feel dumb.

using System;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Text;

using Operations.Teams.Business;

using Operations.Teams.Data;

using Operations.Teams.Reporting;

using Operations.Teams.Reporting.WebControls;

namespace Operations.Teams.Web.ReportControls

{

/// <summary>

/// Summary description for FiscalAgentHierarchy.

/// </summary>

public class FiscalAgentHierarchy : Control, IReportParameterControl,
IPostBackDataHandler

{

public FiscalAgentHierarchy()

{

Parameters.Add(new Parameter("@SchoolYear"));

Parameters.Add(new Parameter("@ReportingGroup"));

Parameters.Add(new Parameter("@FiscalAgentID"));

Parameters.Add(new Parameter("@FundingSourceID"));

Parameters.Add(new Parameter("@ProviderID"));

Parameters.Add(new Parameter("@SiteID"));

Parameters.Add(new Parameter("@ClassID"));

Parameters["@SchoolYear"].Value = 2006;

}


#region Events


public bool LoadPostData(string postDataKey, NameValueCollection postData)

{

string postedValue = postData[postDataKey];

return true;

}

public void RaisePostDataChangedEvent()

{

rysReportingYearSelector_ReportingYearChanged(this, EventArgs.Empty);

}

protected override void LoadViewState(object savedState)

{

string zasdf="asdlfkjds";

}

protected override object SaveViewState()

{

string zsad="asdf";

}

protected override void OnInit(EventArgs e)

{

//this.EnsureChildControls();


// Do whatever the control usually does OnInit

base.OnInit(e);

}

protected override void OnLoad(EventArgs e)

{

//this.EnsureChildControls();

// Do whatever the control usually does OnInit

base.OnLoad(e);

}

private void rysReportingYearSelector_ReportingYearChanged(object sender,
EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void fasFiscalAgent_FiscalAgentChanged(object sender, EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void ddlProviders_SelectedIndexChanged(object sender, EventArgs e)

{

LoadSites();

}

private void ddlSites_SelectedIndexChanged(object sender, EventArgs e)

{

LoadClasses();

}

#endregion

protected override void CreateChildControls()

{

rysReportingYearSelector = new ReportingYearReportSelector();

fasFiscalAgent = new FiscalAgentReportSelector();

this.ddlFundingSource = new DropDownList();

this.ddlProviders = new DropDownList();

this.ddlSites = new DropDownList();

this.ddlClasses = new DropDownList();

rysReportingYearSelector.ID = ReportingYearSelectorControlId;

fasFiscalAgent.ID = FiscalAgentSelectorControlId;

ddlFundingSource.ID = FundingSourceControlId;

ddlProviders.ID = ProvidersControlId;

ddlSites.ID = SitesControlId;

ddlClasses.ID = ClassesControlId;

// Assign these controls' Page property because when they try to access Page
they get null reference - apparently they aren't in the control tree at that
point

rysReportingYearSelector.Page = this.Page;

fasFiscalAgent.Page = this.Page;

rysReportingYearSelector.ReportingYearChanged += new
EventHandler(rysReportingYearSelector_ReportingYearChanged);

fasFiscalAgent.FiscalAgentChanged += new
EventHandler(fasFiscalAgent_FiscalAgentChanged);

ddlProviders.SelectedIndexChanged += new
EventHandler(ddlProviders_SelectedIndexChanged);

ddlSites.SelectedIndexChanged += new
EventHandler(ddlSites_SelectedIndexChanged);

fasFiscalAgent.IsSubmitOnChange = true;

ddlProviders.AutoPostBack = true;

ddlSites.AutoPostBack = true;

// this.SchoolYear = rysReportingYearSelector.SchoolYear;

// check if can populate funding sources and providers (because fiscalAgent
has been saved in session)

if(this.fasFiscalAgent.SelectedFiscalAgentName != string.Empty)

{

LoadFundingSource();

LoadProviders();

}

else

{

ddlFundingSource.Visible = false;

ddlProviders.Visible = false;

}

// Initially set to false until their direct parent's selection has been
made (all other controls will have data on page load)

ddlSites.Visible = false;

ddlClasses.Visible = false;

// start containing table

this.Controls.Add(WebHelper.MakeLiteral("<table cellpadding=0
cellspacing=0><tr><td>"));


this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(rysReportingYearSelector);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(fasFiscalAgent);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Funding
Source</td><td>"));

this.Controls.Add(ddlFundingSource);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
this.Controls.Add(WebHelper.MakeLiteral( said:
this.Controls.Add(ddlClasses);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

// end containing table

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

}

private void LoadFundingSource()

{

int fiscalAgentId = this.fasFiscalAgent.SelectedFiscalAgentId;


if(fiscalAgentId != int.MinValue)

{

this.ddlFundingSource.Visible = true;

this.ddlFundingSource.DataSource = FiscalAgentFunding.Find(fiscalAgentId);

this.ddlFundingSource.DataTextField = "ShortDescription";

this.ddlFundingSource.DataValueField = "CodeId";

this.ddlFundingSource.DataBind();

if(this.ddlFundingSource.Items.Count > 1)

this.ddlFundingSource.Items.Insert(0, new ListItem(string.Empty,
string.Empty));

}

else

{

this.ddlFundingSource.Visible = false;

}

}

private void LoadProviders()

{

int fiscalAgentId = fasFiscalAgent.SelectedFiscalAgentId;

if(fiscalAgentId != int.MinValue)

{

ddlProviders.Visible = true;

ddlProviders.DataSource = FiscalAgentProvider.Find(fiscalAgentId,
rysReportingYearSelector.ReportingYearStartDate,
rysReportingYearSelector.ReportingYearEndDate);

ddlProviders.DataTextField = "ProviderName";

ddlProviders.DataValueField = "ProviderId";

ddlProviders.DataBind();

ddlProviders.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

this.ddlProviders.Items.Clear();

this.ddlProviders.Visible = false;

}

LoadSites();

}

private void LoadSites()

{

if(ddlProviders.SelectedValue != string.Empty)

{

// Load the Site search parameters.

SiteFindArgs siteFindArgs=new SiteFindArgs();
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
tId);

ddlSites.Visible = true;

ddlSites.DataSource = Business.Site.Find(siteFindArgs);

ddlSites.DataTextField = "Name";

ddlSites.DataValueField = "SiteId";

ddlSites.DataBind();

ddlSites.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlSites.Items.Clear();

ddlSites.Visible = false;

}

LoadClasses();

}

private void LoadClasses()

{

if(ddlSites.SelectedValue != string.Empty)

{

ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();

adultEdClassFindArgs.FiscalAgentId =
Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);

adultEdClassFindArgs.ReportingYearStartDate =
rysReportingYearSelector.ReportingYearStartDate;

adultEdClassFindArgs.ReportingYearEndDate =
rysReportingYearSelector.ReportingYearEndDate;

adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;

adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;


ddlClasses.Visible = true;

ddlClasses.DataSource = Class.Find(classFindArgs);

ddlClasses.DataTextField = "Name";

ddlClasses.DataValueField = "ClassId";

ddlClasses.DataBind();

ddlClasses.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlClasses.Items.Clear();

ddlClasses.Visible = false;

}

}



#region Public Properties

#region IReportParameterControl Members

public object ParameterValue

{

get{ return null; }

set{ /*do nothing */ }

}

public ParameterCollection Parameters

{

get{ return parameters; }

set{ parameters = value;}

}

#endregion

public int SchoolYear

{

get{ return (int) ViewState["SchoolYear"]; }

set{ ViewState["SchoolYear"] = value; }

}

#endregion

#region Private Member Variables

private ReportingYearReportSelector rysReportingYearSelector;

private FiscalAgentReportSelector fasFiscalAgent;

private DropDownList ddlFundingSource;

private DropDownList ddlProviders;

private DropDownList ddlSites;

private DropDownList ddlClasses;

private ParameterCollection parameters = new ParameterCollection();

#endregion

#region Private Constants

private const string ReportingYearSelectorControlId =
"rysReportingYearSelector";

private const string FiscalAgentSelectorControlId =
"fasFiscalAgentSelector";

private const string FundingSourceControlId = "ddlFundingSource";

private const string FundingSourceLabelControlId = "lblFundingSource";

private const string ProvidersControlId = "ddlProviders";

private const string ProvidersLabelControlId = "lblProviders";

private const string SitesControlId = "ddlSites";

private const string SitesLabelControlId = "lblSites";

private const string ClassesControlId = "ddlClasses";

private const string ClassesLabelControlId = "lblClasses";

#endregion

}

}
 
T

TS

I think i maybe should be doing this at all because i can just access the
control's value because that control handles the functionality automatically
that I was trying to do.

If this is so, then i still have a problem: How do i raise events in my
control for controls i have created in createchildcontrols? I have the
controls wired up to event handlers, but they are never hit.

What do i need to do?

thanks

TS said:
i followed the article at:
http://msdn.microsoft.com/library/d...de/html/cpconpostbackdataprocessingsample.asp
and it works like that except like i said when I use createchildControls
instead of render (because i need to render multiple controls), it doesn't
hit those postback methods.

thanks again

TS said:
Well i know it has something to do with the CREATEChildControls method
because when i overrode render instead of doing that method at all, the
LoadPostData() was executed. I guess it has something to do with the
controls being recreated each time, I DON"T KNOW.

I need help all of you master coders :)


TS said:
i have a composite control that has dropdowns on them. The page will post
back on change, but their events won't raise. Can anyone tell me whats going
on? I tried to use the IPostBackDataHandler to try to get a hold of the
control to set values and such, but it has been no help. I'm confused
at
how
this control is supposed to work. I want it to be self contained so that
when a control changes, it posts back and then reloads its dependent drop
down lists with data that is filtered based on the value of the
control
that
changed.

Every time the page posts back to server, the it hits the init and load
events and createchildcontrols, but thats it. i can't get into the
XXX_SelectedIndexChanged events for some reason even though they are wired
to do so.

Any help will be appreaciated as i'm starting to feel dumb.

using System;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Text;

using Operations.Teams.Business;

using Operations.Teams.Data;

using Operations.Teams.Reporting;

using Operations.Teams.Reporting.WebControls;

namespace Operations.Teams.Web.ReportControls

{

/// <summary>

/// Summary description for FiscalAgentHierarchy.

/// </summary>

public class FiscalAgentHierarchy : Control, IReportParameterControl,
IPostBackDataHandler

{

public FiscalAgentHierarchy()

{

Parameters.Add(new Parameter("@SchoolYear"));

Parameters.Add(new Parameter("@ReportingGroup"));

Parameters.Add(new Parameter("@FiscalAgentID"));

Parameters.Add(new Parameter("@FundingSourceID"));

Parameters.Add(new Parameter("@ProviderID"));

Parameters.Add(new Parameter("@SiteID"));

Parameters.Add(new Parameter("@ClassID"));

Parameters["@SchoolYear"].Value = 2006;

}


#region Events


public bool LoadPostData(string postDataKey, NameValueCollection postData)

{

string postedValue = postData[postDataKey];

return true;

}

public void RaisePostDataChangedEvent()

{

rysReportingYearSelector_ReportingYearChanged(this, EventArgs.Empty);

}

protected override void LoadViewState(object savedState)

{

string zasdf="asdlfkjds";

}

protected override object SaveViewState()

{

string zsad="asdf";

}

protected override void OnInit(EventArgs e)

{

//this.EnsureChildControls();


// Do whatever the control usually does OnInit

base.OnInit(e);

}

protected override void OnLoad(EventArgs e)

{

//this.EnsureChildControls();

// Do whatever the control usually does OnInit

base.OnLoad(e);

}

private void rysReportingYearSelector_ReportingYearChanged(object sender,
EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void fasFiscalAgent_FiscalAgentChanged(object sender,
EventArgs
EventArgs
e) access
Page at
that
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
tId);

ddlSites.Visible = true;

ddlSites.DataSource = Business.Site.Find(siteFindArgs);

ddlSites.DataTextField = "Name";

ddlSites.DataValueField = "SiteId";

ddlSites.DataBind();

ddlSites.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlSites.Items.Clear();

ddlSites.Visible = false;

}

LoadClasses();

}

private void LoadClasses()

{

if(ddlSites.SelectedValue != string.Empty)

{

ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();

adultEdClassFindArgs.FiscalAgentId =
Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);

adultEdClassFindArgs.ReportingYearStartDate =
rysReportingYearSelector.ReportingYearStartDate;

adultEdClassFindArgs.ReportingYearEndDate =
rysReportingYearSelector.ReportingYearEndDate;

adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;

adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;


ddlClasses.Visible = true;

ddlClasses.DataSource = Class.Find(classFindArgs);

ddlClasses.DataTextField = "Name";

ddlClasses.DataValueField = "ClassId";

ddlClasses.DataBind();

ddlClasses.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlClasses.Items.Clear();

ddlClasses.Visible = false;

}

}



#region Public Properties

#region IReportParameterControl Members

public object ParameterValue

{

get{ return null; }

set{ /*do nothing */ }

}

public ParameterCollection Parameters

{

get{ return parameters; }

set{ parameters = value;}

}

#endregion

public int SchoolYear

{

get{ return (int) ViewState["SchoolYear"]; }

set{ ViewState["SchoolYear"] = value; }

}

#endregion

#region Private Member Variables

private ReportingYearReportSelector rysReportingYearSelector;

private FiscalAgentReportSelector fasFiscalAgent;

private DropDownList ddlFundingSource;

private DropDownList ddlProviders;

private DropDownList ddlSites;

private DropDownList ddlClasses;

private ParameterCollection parameters = new ParameterCollection();

#endregion

#region Private Constants

private const string ReportingYearSelectorControlId =
"rysReportingYearSelector";

private const string FiscalAgentSelectorControlId =
"fasFiscalAgentSelector";

private const string FundingSourceControlId = "ddlFundingSource";

private const string FundingSourceLabelControlId = "lblFundingSource";

private const string ProvidersControlId = "ddlProviders";

private const string ProvidersLabelControlId = "lblProviders";

private const string SitesControlId = "ddlSites";

private const string SitesLabelControlId = "lblSites";

private const string ClassesControlId = "ddlClasses";

private const string ClassesLabelControlId = "lblClasses";

#endregion

}

}
 
T

TS

I figured it out, i wasnt' implementing INamingContainer. that fixes
it...BUT WHY DOES THIS IMPACT IF EVENTS GET FIRED OR NOT????


TS said:
I think i maybe should be doing this at all because i can just access the
control's value because that control handles the functionality automatically
that I was trying to do.

If this is so, then i still have a problem: How do i raise events in my
control for controls i have created in createchildcontrols? I have the
controls wired up to event handlers, but they are never hit.

What do i need to do?

thanks

TS said:
i followed the article at:
http://msdn.microsoft.com/library/d...de/html/cpconpostbackdataprocessingsample.asp
and it works like that except like i said when I use createchildControls
instead of render (because i need to render multiple controls), it doesn't
hit those postback methods.

thanks again
confused
at
how
this control is supposed to work. I want it to be self contained so that
when a control changes, it posts back and then reloads its dependent drop
down lists with data that is filtered based on the value of the control
that
changed.

Every time the page posts back to server, the it hits the init and load
events and createchildcontrols, but thats it. i can't get into the
XXX_SelectedIndexChanged events for some reason even though they are wired
to do so.

Any help will be appreaciated as i'm starting to feel dumb.

using System;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Text;

using Operations.Teams.Business;

using Operations.Teams.Data;

using Operations.Teams.Reporting;

using Operations.Teams.Reporting.WebControls;

namespace Operations.Teams.Web.ReportControls

{

/// <summary>

/// Summary description for FiscalAgentHierarchy.

/// </summary>

public class FiscalAgentHierarchy : Control, IReportParameterControl,
IPostBackDataHandler

{

public FiscalAgentHierarchy()

{

Parameters.Add(new Parameter("@SchoolYear"));

Parameters.Add(new Parameter("@ReportingGroup"));

Parameters.Add(new Parameter("@FiscalAgentID"));

Parameters.Add(new Parameter("@FundingSourceID"));

Parameters.Add(new Parameter("@ProviderID"));

Parameters.Add(new Parameter("@SiteID"));

Parameters.Add(new Parameter("@ClassID"));

Parameters["@SchoolYear"].Value = 2006;

}


#region Events


public bool LoadPostData(string postDataKey, NameValueCollection postData)

{

string postedValue = postData[postDataKey];

return true;

}

public void RaisePostDataChangedEvent()

{

rysReportingYearSelector_ReportingYearChanged(this, EventArgs.Empty);

}

protected override void LoadViewState(object savedState)

{

string zasdf="asdlfkjds";

}

protected override object SaveViewState()

{

string zsad="asdf";

}

protected override void OnInit(EventArgs e)

{

//this.EnsureChildControls();


// Do whatever the control usually does OnInit

base.OnInit(e);

}

protected override void OnLoad(EventArgs e)

{

//this.EnsureChildControls();

// Do whatever the control usually does OnInit

base.OnLoad(e);

}

private void rysReportingYearSelector_ReportingYearChanged(object sender,
EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void fasFiscalAgent_FiscalAgentChanged(object sender,
EventArgs
e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void ddlProviders_SelectedIndexChanged(object sender,
EventArgs
e)

{

LoadSites();

}

private void ddlSites_SelectedIndexChanged(object sender, EventArgs e)

{

LoadClasses();

}

#endregion

protected override void CreateChildControls()

{

rysReportingYearSelector = new ReportingYearReportSelector();

fasFiscalAgent = new FiscalAgentReportSelector();

this.ddlFundingSource = new DropDownList();

this.ddlProviders = new DropDownList();

this.ddlSites = new DropDownList();

this.ddlClasses = new DropDownList();

rysReportingYearSelector.ID = ReportingYearSelectorControlId;

fasFiscalAgent.ID = FiscalAgentSelectorControlId;

ddlFundingSource.ID = FundingSourceControlId;

ddlProviders.ID = ProvidersControlId;

ddlSites.ID = SitesControlId;

ddlClasses.ID = ClassesControlId;

// Assign these controls' Page property because when they try to access
Page
they get null reference - apparently they aren't in the control tree at
that
point

rysReportingYearSelector.Page = this.Page;

fasFiscalAgent.Page = this.Page;

rysReportingYearSelector.ReportingYearChanged += new
EventHandler(rysReportingYearSelector_ReportingYearChanged);

fasFiscalAgent.FiscalAgentChanged += new
EventHandler(fasFiscalAgent_FiscalAgentChanged);

ddlProviders.SelectedIndexChanged += new
EventHandler(ddlProviders_SelectedIndexChanged);

ddlSites.SelectedIndexChanged += new
EventHandler(ddlSites_SelectedIndexChanged);

fasFiscalAgent.IsSubmitOnChange = true;

ddlProviders.AutoPostBack = true;

ddlSites.AutoPostBack = true;

// this.SchoolYear = rysReportingYearSelector.SchoolYear;

// check if can populate funding sources and providers (because
fiscalAgent
has been saved in session)

if(this.fasFiscalAgent.SelectedFiscalAgentName != string.Empty)

{

LoadFundingSource();

LoadProviders();

}

else

{

ddlFundingSource.Visible = false;

ddlProviders.Visible = false;

}

// Initially set to false until their direct parent's selection has been
made (all other controls will have data on page load)

ddlSites.Visible = false;

ddlClasses.Visible = false;

// start containing table

this.Controls.Add(WebHelper.MakeLiteral("<table cellpadding=0
cellspacing=0><tr><td>"));


this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(rysReportingYearSelector);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));

this.Controls.Add(fasFiscalAgent);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));

this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Funding
Source</td><td>"));

this.Controls.Add(ddlFundingSource);

this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));

this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
tId);

ddlSites.Visible = true;

ddlSites.DataSource = Business.Site.Find(siteFindArgs);

ddlSites.DataTextField = "Name";

ddlSites.DataValueField = "SiteId";

ddlSites.DataBind();

ddlSites.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlSites.Items.Clear();

ddlSites.Visible = false;

}

LoadClasses();

}

private void LoadClasses()

{

if(ddlSites.SelectedValue != string.Empty)

{

ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();

adultEdClassFindArgs.FiscalAgentId =
Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);

adultEdClassFindArgs.ReportingYearStartDate =
rysReportingYearSelector.ReportingYearStartDate;

adultEdClassFindArgs.ReportingYearEndDate =
rysReportingYearSelector.ReportingYearEndDate;

adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;

adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;


ddlClasses.Visible = true;

ddlClasses.DataSource = Class.Find(classFindArgs);

ddlClasses.DataTextField = "Name";

ddlClasses.DataValueField = "ClassId";

ddlClasses.DataBind();

ddlClasses.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlClasses.Items.Clear();

ddlClasses.Visible = false;

}

}



#region Public Properties

#region IReportParameterControl Members

public object ParameterValue

{

get{ return null; }

set{ /*do nothing */ }

}

public ParameterCollection Parameters

{

get{ return parameters; }

set{ parameters = value;}

}

#endregion

public int SchoolYear

{

get{ return (int) ViewState["SchoolYear"]; }

set{ ViewState["SchoolYear"] = value; }

}

#endregion

#region Private Member Variables

private ReportingYearReportSelector rysReportingYearSelector;

private FiscalAgentReportSelector fasFiscalAgent;

private DropDownList ddlFundingSource;

private DropDownList ddlProviders;

private DropDownList ddlSites;

private DropDownList ddlClasses;

private ParameterCollection parameters = new ParameterCollection();

#endregion

#region Private Constants

private const string ReportingYearSelectorControlId =
"rysReportingYearSelector";

private const string FiscalAgentSelectorControlId =
"fasFiscalAgentSelector";

private const string FundingSourceControlId = "ddlFundingSource";

private const string FundingSourceLabelControlId = "lblFundingSource";

private const string ProvidersControlId = "ddlProviders";

private const string ProvidersLabelControlId = "lblProviders";

private const string SitesControlId = "ddlSites";

private const string SitesLabelControlId = "lblSites";

private const string ClassesControlId = "ddlClasses";

private const string ClassesLabelControlId = "lblClasses";

#endregion

}

}
 
T

TS

I have a new issue:

One of my controls in my composite control is in itself a composite control.
It has an event that is raised when one of its drop down lists selected
index changes. In main composite control, i hook into this other control's
event so that i can do processing. This event won't fire in either the drop
down list's selected index change event handler and also not in the event
handler that my main control subscribes to.

I have a clue that may be the reason: In this sub composite control, it
tries to access the page property, which is null when it's
CreateChildControls. So how i fixed it was to assign this composite
control's page property to my main control's page property so that it now
can access the page property. I'm wondering if this has something to do with
the event not firing.

thanks

TS said:
I figured it out, i wasnt' implementing INamingContainer. that fixes
it...BUT WHY DOES THIS IMPACT IF EVENTS GET FIRED OR NOT????


TS said:
I think i maybe should be doing this at all because i can just access the
control's value because that control handles the functionality automatically
that I was trying to do.

If this is so, then i still have a problem: How do i raise events in my
control for controls i have created in createchildcontrols? I have the
controls wired up to event handlers, but they are never hit.

What do i need to do?

thanks
http://msdn.microsoft.com/library/d...de/html/cpconpostbackdataprocessingsample.asp
and it works like that except like i said when I use createchildControls
instead of render (because i need to render multiple controls), it doesn't
hit those postback methods.

thanks again

Well i know it has something to do with the CREATEChildControls method
because when i overrode render instead of doing that method at all, the
LoadPostData() was executed. I guess it has something to do with the
controls being recreated each time, I DON"T KNOW.

I need help all of you master coders :)


i have a composite control that has dropdowns on them. The page will
post
back on change, but their events won't raise. Can anyone tell me whats
going
on? I tried to use the IPostBackDataHandler to try to get a hold
of
the
control to set values and such, but it has been no help. I'm
confused
at
how
this control is supposed to work. I want it to be self contained
so
that
when a control changes, it posts back and then reloads its dependent
drop
down lists with data that is filtered based on the value of the control
that
changed.

Every time the page posts back to server, the it hits the init and load
events and createchildcontrols, but thats it. i can't get into the
XXX_SelectedIndexChanged events for some reason even though they are
wired
to do so.

Any help will be appreaciated as i'm starting to feel dumb.

using System;

using System.Collections.Specialized;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Text;

using Operations.Teams.Business;

using Operations.Teams.Data;

using Operations.Teams.Reporting;

using Operations.Teams.Reporting.WebControls;

namespace Operations.Teams.Web.ReportControls

{

/// <summary>

/// Summary description for FiscalAgentHierarchy.

/// </summary>

public class FiscalAgentHierarchy : Control, IReportParameterControl,
IPostBackDataHandler

{

public FiscalAgentHierarchy()

{

Parameters.Add(new Parameter("@SchoolYear"));

Parameters.Add(new Parameter("@ReportingGroup"));

Parameters.Add(new Parameter("@FiscalAgentID"));

Parameters.Add(new Parameter("@FundingSourceID"));

Parameters.Add(new Parameter("@ProviderID"));

Parameters.Add(new Parameter("@SiteID"));

Parameters.Add(new Parameter("@ClassID"));

Parameters["@SchoolYear"].Value = 2006;

}


#region Events


public bool LoadPostData(string postDataKey, NameValueCollection
postData)

{

string postedValue = postData[postDataKey];

return true;

}

public void RaisePostDataChangedEvent()

{

rysReportingYearSelector_ReportingYearChanged(this, EventArgs.Empty);

}

protected override void LoadViewState(object savedState)

{

string zasdf="asdlfkjds";

}

protected override object SaveViewState()

{

string zsad="asdf";

}

protected override void OnInit(EventArgs e)

{

//this.EnsureChildControls();


// Do whatever the control usually does OnInit

base.OnInit(e);

}

protected override void OnLoad(EventArgs e)

{

//this.EnsureChildControls();

// Do whatever the control usually does OnInit

base.OnLoad(e);

}

private void rysReportingYearSelector_ReportingYearChanged(object
sender,
EventArgs e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void fasFiscalAgent_FiscalAgentChanged(object sender, EventArgs
e)

{

this.LoadFundingSource();

this.LoadProviders();

}

private void ddlProviders_SelectedIndexChanged(object sender, EventArgs
e)

{

LoadSites();

}

private void ddlSites_SelectedIndexChanged(object sender,
EventArgs
e) tree
at has
been
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
tId);

ddlSites.Visible = true;

ddlSites.DataSource = Business.Site.Find(siteFindArgs);

ddlSites.DataTextField = "Name";

ddlSites.DataValueField = "SiteId";

ddlSites.DataBind();

ddlSites.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlSites.Items.Clear();

ddlSites.Visible = false;

}

LoadClasses();

}

private void LoadClasses()

{

if(ddlSites.SelectedValue != string.Empty)

{

ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();

adultEdClassFindArgs.FiscalAgentId =
Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);

adultEdClassFindArgs.ReportingYearStartDate =
rysReportingYearSelector.ReportingYearStartDate;

adultEdClassFindArgs.ReportingYearEndDate =
rysReportingYearSelector.ReportingYearEndDate;

adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;

adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;


ddlClasses.Visible = true;

ddlClasses.DataSource = Class.Find(classFindArgs);

ddlClasses.DataTextField = "Name";

ddlClasses.DataValueField = "ClassId";

ddlClasses.DataBind();

ddlClasses.Items.Insert(0, new ListItem(string.Empty, string.Empty));

}

else

{

ddlClasses.Items.Clear();

ddlClasses.Visible = false;

}

}



#region Public Properties

#region IReportParameterControl Members

public object ParameterValue

{

get{ return null; }

set{ /*do nothing */ }

}

public ParameterCollection Parameters

{

get{ return parameters; }

set{ parameters = value;}

}

#endregion

public int SchoolYear

{

get{ return (int) ViewState["SchoolYear"]; }

set{ ViewState["SchoolYear"] = value; }

}

#endregion

#region Private Member Variables

private ReportingYearReportSelector rysReportingYearSelector;

private FiscalAgentReportSelector fasFiscalAgent;

private DropDownList ddlFundingSource;

private DropDownList ddlProviders;

private DropDownList ddlSites;

private DropDownList ddlClasses;

private ParameterCollection parameters = new ParameterCollection();

#endregion

#region Private Constants

private const string ReportingYearSelectorControlId =
"rysReportingYearSelector";

private const string FiscalAgentSelectorControlId =
"fasFiscalAgentSelector";

private const string FundingSourceControlId = "ddlFundingSource";

private const string FundingSourceLabelControlId = "lblFundingSource";

private const string ProvidersControlId = "ddlProviders";

private const string ProvidersLabelControlId = "lblProviders";

private const string SitesControlId = "ddlSites";

private const string SitesLabelControlId = "lblSites";

private const string ClassesControlId = "ddlClasses";

private const string ClassesLabelControlId = "lblClasses";

#endregion

}

}
 
S

Steven Cheng[MSFT]

Hi TS,

Welcome to ASPNET newsgroup.
Regarding on the post back event handling problem in composite control,
generaly speaking , the most likely cause is still the event handler's
registering sequence and the control's constructing and adding approach.

For your former problem, (postback event for sub controls not fire when the
composite control doesn't implement INamingContainer), this is because for
sub controls contained in composite control, they need to be assigned an
unique clientID which will be used when it's postback event be fired( the
runtime will use this ID to mapping the event to the correct control
instance). When we didn't implement NamingContainer interface, the
composite control won't assign the appropriate ClientID(also UniqueID) for
the nested sub controls, so sub controls' post back event won't be handled
correclty.

As for the new problem you mentioned, I'm wondering how did you create your
composite control (also its nested sub composite controls inside it)? For
the "Page" property, it'll be assigned properly when a certain control is
added into its container control's Controls collection, we don't need to
manually assign it. Anyway, would you try provide some code snippet to
represent your composite control's code logic? It'll be much helpful if you
can make a very simple repro demo control to demostrate the problem.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)






--------------------
| From: "TS" <[email protected]>
| References: <#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: processing postback
| Date: Tue, 2 Aug 2005 15:54:05 -0500
| Lines: 717
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups:
microsoft.public.dotnet.framework.aspnet.buildingcontrols,microsoft.public.d
otnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: 103nat100.tea.state.tx.us 198.214.103.100
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:10237
microsoft.public.dotnet.framework.aspnet.buildingcontrols:3976
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| I have a new issue:
|
| One of my controls in my composite control is in itself a composite
control.
| It has an event that is raised when one of its drop down lists selected
| index changes. In main composite control, i hook into this other control's
| event so that i can do processing. This event won't fire in either the
drop
| down list's selected index change event handler and also not in the event
| handler that my main control subscribes to.
|
| I have a clue that may be the reason: In this sub composite control, it
| tries to access the page property, which is null when it's
| CreateChildControls. So how i fixed it was to assign this composite
| control's page property to my main control's page property so that it now
| can access the page property. I'm wondering if this has something to do
with
| the event not firing.
|
| thanks
|
| | > I figured it out, i wasnt' implementing INamingContainer. that fixes
| > it...BUT WHY DOES THIS IMPACT IF EVENTS GET FIRED OR NOT????
| >
| >
| > | > > I think i maybe should be doing this at all because i can just access
| the
| > > control's value because that control handles the functionality
| > automatically
| > > that I was trying to do.
| > >
| > > If this is so, then i still have a problem: How do i raise events in
my
| > > control for controls i have created in createchildcontrols? I have the
| > > controls wired up to event handlers, but they are never hit.
| > >
| > > What do i need to do?
| > >
| > > thanks
| > >
| > > | > > > i followed the article at:
| > > >
| > >
| >
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconpostbackdataprocessingsample.asp
| > > > and it works like that except like i said when I use
| createchildControls
| > > > instead of render (because i need to render multiple controls), it
| > doesn't
| > > > hit those postback methods.
| > > >
| > > > thanks again
| > > >
| > > > | > > > > Well i know it has something to do with the CREATEChildControls
| method
| > > > > because when i overrode render instead of doing that method at
all,
| > the
| > > > > LoadPostData() was executed. I guess it has something to do with
the
| > > > > controls being recreated each time, I DON"T KNOW.
| > > > >
| > > > > I need help all of you master coders :)
| > > > >
| > > > >
| > > > > | > > > > > i have a composite control that has dropdowns on them. The page
| will
| > > > post
| > > > > > back on change, but their events won't raise. Can anyone tell me
| > whats
| > > > > going
| > > > > > on? I tried to use the IPostBackDataHandler to try to get a hold
| of
| > > the
| > > > > > control to set values and such, but it has been no help. I'm
| > confused
| > > at
| > > > > how
| > > > > > this control is supposed to work. I want it to be self contained
| so
| > > that
| > > > > > when a control changes, it posts back and then reloads its
| dependent
| > > > drop
| > > > > > down lists with data that is filtered based on the value of the
| > > control
| > > > > that
| > > > > > changed.
| > > > > >
| > > > > > Every time the page posts back to server, the it hits the init
and
| > > load
| > > > > > events and createchildcontrols, but thats it. i can't get into
the
| > > > > > XXX_SelectedIndexChanged events for some reason even though they
| are
| > > > wired
| > > > > > to do so.
| > > > > >
| > > > > > Any help will be appreaciated as i'm starting to feel dumb.
| > > > > >
| > > > > > using System;
| > > > > >
| > > > > > using System.Collections.Specialized;
| > > > > >
| > > > > > using System.Web.UI;
| > > > > >
| > > > > > using System.Web.UI.WebControls;
| > > > > >
| > > > > > using System.Text;
| > > > > >
| > > > > > using Operations.Teams.Business;
| > > > > >
| > > > > > using Operations.Teams.Data;
| > > > > >
| > > > > > using Operations.Teams.Reporting;
| > > > > >
| > > > > > using Operations.Teams.Reporting.WebControls;
| > > > > >
| > > > > > namespace Operations.Teams.Web.ReportControls
| > > > > >
| > > > > > {
| > > > > >
| > > > > > /// <summary>
| > > > > >
| > > > > > /// Summary description for FiscalAgentHierarchy.
| > > > > >
| > > > > > /// </summary>
| > > > > >
| > > > > > public class FiscalAgentHierarchy : Control,
| > IReportParameterControl,
| > > > > > IPostBackDataHandler
| > > > > >
| > > > > > {
| > > > > >
| > > > > > public FiscalAgentHierarchy()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > Parameters.Add(new Parameter("@SchoolYear"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@ReportingGroup"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@FiscalAgentID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@FundingSourceID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@ProviderID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@SiteID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@ClassID"));
| > > > > >
| > > > > > Parameters["@SchoolYear"].Value = 2006;
| > > > > >
| > > > > > }
| > > > > >
| > > > > >
| > > > > > #region Events
| > > > > >
| > > > > >
| > > > > > public bool LoadPostData(string postDataKey, NameValueCollection
| > > > postData)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > string postedValue = postData[postDataKey];
| > > > > >
| > > > > > return true;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > public void RaisePostDataChangedEvent()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > rysReportingYearSelector_ReportingYearChanged(this,
| > EventArgs.Empty);
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override void LoadViewState(object savedState)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > string zasdf="asdlfkjds";
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override object SaveViewState()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > string zsad="asdf";
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override void OnInit(EventArgs e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > //this.EnsureChildControls();
| > > > > >
| > > > > >
| > > > > > // Do whatever the control usually does OnInit
| > > > > >
| > > > > > base.OnInit(e);
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override void OnLoad(EventArgs e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > //this.EnsureChildControls();
| > > > > >
| > > > > > // Do whatever the control usually does OnInit
| > > > > >
| > > > > > base.OnLoad(e);
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void
rysReportingYearSelector_ReportingYearChanged(object
| > > > sender,
| > > > > > EventArgs e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.LoadFundingSource();
| > > > > >
| > > > > > this.LoadProviders();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void fasFiscalAgent_FiscalAgentChanged(object sender,
| > > EventArgs
| > > > e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.LoadFundingSource();
| > > > > >
| > > > > > this.LoadProviders();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void ddlProviders_SelectedIndexChanged(object sender,
| > > EventArgs
| > > > e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > LoadSites();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void ddlSites_SelectedIndexChanged(object sender,
| EventArgs
| > e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > LoadClasses();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > protected override void CreateChildControls()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > rysReportingYearSelector = new ReportingYearReportSelector();
| > > > > >
| > > > > > fasFiscalAgent = new FiscalAgentReportSelector();
| > > > > >
| > > > > > this.ddlFundingSource = new DropDownList();
| > > > > >
| > > > > > this.ddlProviders = new DropDownList();
| > > > > >
| > > > > > this.ddlSites = new DropDownList();
| > > > > >
| > > > > > this.ddlClasses = new DropDownList();
| > > > > >
| > > > > > rysReportingYearSelector.ID = ReportingYearSelectorControlId;
| > > > > >
| > > > > > fasFiscalAgent.ID = FiscalAgentSelectorControlId;
| > > > > >
| > > > > > ddlFundingSource.ID = FundingSourceControlId;
| > > > > >
| > > > > > ddlProviders.ID = ProvidersControlId;
| > > > > >
| > > > > > ddlSites.ID = SitesControlId;
| > > > > >
| > > > > > ddlClasses.ID = ClassesControlId;
| > > > > >
| > > > > > // Assign these controls' Page property because when they try to
| > > access
| > > > > Page
| > > > > > they get null reference - apparently they aren't in the control
| tree
| > > at
| > > > > that
| > > > > > point
| > > > > >
| > > > > > rysReportingYearSelector.Page = this.Page;
| > > > > >
| > > > > > fasFiscalAgent.Page = this.Page;
| > > > > >
| > > > > > rysReportingYearSelector.ReportingYearChanged += new
| > > > > > EventHandler(rysReportingYearSelector_ReportingYearChanged);
| > > > > >
| > > > > > fasFiscalAgent.FiscalAgentChanged += new
| > > > > > EventHandler(fasFiscalAgent_FiscalAgentChanged);
| > > > > >
| > > > > > ddlProviders.SelectedIndexChanged += new
| > > > > > EventHandler(ddlProviders_SelectedIndexChanged);
| > > > > >
| > > > > > ddlSites.SelectedIndexChanged += new
| > > > > > EventHandler(ddlSites_SelectedIndexChanged);
| > > > > >
| > > > > > fasFiscalAgent.IsSubmitOnChange = true;
| > > > > >
| > > > > > ddlProviders.AutoPostBack = true;
| > > > > >
| > > > > > ddlSites.AutoPostBack = true;
| > > > > >
| > > > > > // this.SchoolYear = rysReportingYearSelector.SchoolYear;
| > > > > >
| > > > > > // check if can populate funding sources and providers (because
| > > > > fiscalAgent
| > > > > > has been saved in session)
| > > > > >
| > > > > > if(this.fasFiscalAgent.SelectedFiscalAgentName != string.Empty)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > LoadFundingSource();
| > > > > >
| > > > > > LoadProviders();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlFundingSource.Visible = false;
| > > > > >
| > > > > > ddlProviders.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > // Initially set to false until their direct parent's selection
| has
| > > been
| > > > > > made (all other controls will have data on page load)
| > > > > >
| > > > > > ddlSites.Visible = false;
| > > > > >
| > > > > > ddlClasses.Visible = false;
| > > > > >
| > > > > > // start containing table
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table cellpadding=0
| > > > > > cellspacing=0><tr><td>"));
| > > > > >
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));
| > > > > >
| > > > > > this.Controls.Add(rysReportingYearSelector);
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));
| > > > > >
| > > > > > this.Controls.Add(fasFiscalAgent);
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Funding
| > > > > > Source</td><td>"));
| > > > > >
| > > > > > this.Controls.Add(ddlFundingSource);
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > > > > >
| > > > > >
| > > > >
| > > >
| > >
| >
|
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Providers</td><td>")
| > > > > > );
| > > > > >
| > > > > > this.Controls.Add(ddlProviders);
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > > > > >
| > > > > >
| > > >
| >
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Sites</td><td>"));
| > > > > >
| > > > > > this.Controls.Add(ddlSites);
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > > > > >
| > > > > >
| > > > >
| > > >
| > >
| >
|
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Classes</td><td>"));
| > > > > >
| > > > > > this.Controls.Add(ddlClasses);
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > // end containing table
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadFundingSource()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > int fiscalAgentId = this.fasFiscalAgent.SelectedFiscalAgentId;
| > > > > >
| > > > > >
| > > > > > if(fiscalAgentId != int.MinValue)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.ddlFundingSource.Visible = true;
| > > > > >
| > > > > > this.ddlFundingSource.DataSource =
| > > > FiscalAgentFunding.Find(fiscalAgentId);
| > > > > >
| > > > > > this.ddlFundingSource.DataTextField = "ShortDescription";
| > > > > >
| > > > > > this.ddlFundingSource.DataValueField = "CodeId";
| > > > > >
| > > > > > this.ddlFundingSource.DataBind();
| > > > > >
| > > > > > if(this.ddlFundingSource.Items.Count > 1)
| > > > > >
| > > > > > this.ddlFundingSource.Items.Insert(0, new ListItem(string.Empty,
| > > > > > string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.ddlFundingSource.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadProviders()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > int fiscalAgentId = fasFiscalAgent.SelectedFiscalAgentId;
| > > > > >
| > > > > > if(fiscalAgentId != int.MinValue)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlProviders.Visible = true;
| > > > > >
| > > > > > ddlProviders.DataSource =
FiscalAgentProvider.Find(fiscalAgentId,
| > > > > > rysReportingYearSelector.ReportingYearStartDate,
| > > > > > rysReportingYearSelector.ReportingYearEndDate);
| > > > > >
| > > > > > ddlProviders.DataTextField = "ProviderName";
| > > > > >
| > > > > > ddlProviders.DataValueField = "ProviderId";
| > > > > >
| > > > > > ddlProviders.DataBind();
| > > > > >
| > > > > > ddlProviders.Items.Insert(0, new ListItem(string.Empty,
| > > string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.ddlProviders.Items.Clear();
| > > > > >
| > > > > > this.ddlProviders.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > LoadSites();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadSites()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > if(ddlProviders.SelectedValue != string.Empty)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > // Load the Site search parameters.
| > > > > >
| > > > > > SiteFindArgs siteFindArgs=new SiteFindArgs();
| > > > > >
| > > > > >
| > > > >
| > > >
| > >
| >
|
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
| > > > > > tId);
| > > > > >
| > > > > > ddlSites.Visible = true;
| > > > > >
| > > > > > ddlSites.DataSource = Business.Site.Find(siteFindArgs);
| > > > > >
| > > > > > ddlSites.DataTextField = "Name";
| > > > > >
| > > > > > ddlSites.DataValueField = "SiteId";
| > > > > >
| > > > > > ddlSites.DataBind();
| > > > > >
| > > > > > ddlSites.Items.Insert(0, new ListItem(string.Empty,
| string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlSites.Items.Clear();
| > > > > >
| > > > > > ddlSites.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > LoadClasses();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadClasses()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > if(ddlSites.SelectedValue != string.Empty)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();
| > > > > >
| > > > > > adultEdClassFindArgs.FiscalAgentId =
| > > > > > Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);
| > > > > >
| > > > > > adultEdClassFindArgs.ReportingYearStartDate =
| > > > > > rysReportingYearSelector.ReportingYearStartDate;
| > > > > >
| > > > > > adultEdClassFindArgs.ReportingYearEndDate =
| > > > > > rysReportingYearSelector.ReportingYearEndDate;
| > > > > >
| > > > > > adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;
| > > > > >
| > > > > > adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;
| > > > > >
| > > > > >
| > > > > > ddlClasses.Visible = true;
| > > > > >
| > > > > > ddlClasses.DataSource = Class.Find(classFindArgs);
| > > > > >
| > > > > > ddlClasses.DataTextField = "Name";
| > > > > >
| > > > > > ddlClasses.DataValueField = "ClassId";
| > > > > >
| > > > > > ddlClasses.DataBind();
| > > > > >
| > > > > > ddlClasses.Items.Insert(0, new ListItem(string.Empty,
| > string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlClasses.Items.Clear();
| > > > > >
| > > > > > ddlClasses.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > }
| > > > > >
| > > > > >
| > > > > >
| > > > > > #region Public Properties
| > > > > >
| > > > > > #region IReportParameterControl Members
| > > > > >
| > > > > > public object ParameterValue
| > > > > >
| > > > > > {
| > > > > >
| > > > > > get{ return null; }
| > > > > >
| > > > > > set{ /*do nothing */ }
| > > > > >
| > > > > > }
| > > > > >
| > > > > > public ParameterCollection Parameters
| > > > > >
| > > > > > {
| > > > > >
| > > > > > get{ return parameters; }
| > > > > >
| > > > > > set{ parameters = value;}
| > > > > >
| > > > > > }
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > public int SchoolYear
| > > > > >
| > > > > > {
| > > > > >
| > > > > > get{ return (int) ViewState["SchoolYear"]; }
| > > > > >
| > > > > > set{ ViewState["SchoolYear"] = value; }
| > > > > >
| > > > > > }
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > #region Private Member Variables
| > > > > >
| > > > > > private ReportingYearReportSelector rysReportingYearSelector;
| > > > > >
| > > > > > private FiscalAgentReportSelector fasFiscalAgent;
| > > > > >
| > > > > > private DropDownList ddlFundingSource;
| > > > > >
| > > > > > private DropDownList ddlProviders;
| > > > > >
| > > > > > private DropDownList ddlSites;
| > > > > >
| > > > > > private DropDownList ddlClasses;
| > > > > >
| > > > > > private ParameterCollection parameters = new
| ParameterCollection();
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > #region Private Constants
| > > > > >
| > > > > > private const string ReportingYearSelectorControlId =
| > > > > > "rysReportingYearSelector";
| > > > > >
| > > > > > private const string FiscalAgentSelectorControlId =
| > > > > > "fasFiscalAgentSelector";
| > > > > >
| > > > > > private const string FundingSourceControlId =
"ddlFundingSource";
| > > > > >
| > > > > > private const string FundingSourceLabelControlId =
| > "lblFundingSource";
| > > > > >
| > > > > > private const string ProvidersControlId = "ddlProviders";
| > > > > >
| > > > > > private const string ProvidersLabelControlId = "lblProviders";
| > > > > >
| > > > > > private const string SitesControlId = "ddlSites";
| > > > > >
| > > > > > private const string SitesLabelControlId = "lblSites";
| > > > > >
| > > > > > private const string ClassesControlId = "ddlClasses";
| > > > > >
| > > > > > private const string ClassesLabelControlId = "lblClasses";
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > }
| > > > > >
| > > > > > }
| > > > > >
| > > > > >
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|
 
T

TS

thanks, but it seems my only problem that still exists is the posts i'm
making in "explanation of when need..."


Steven Cheng said:
Hi TS,

Welcome to ASPNET newsgroup.
Regarding on the post back event handling problem in composite control,
generaly speaking , the most likely cause is still the event handler's
registering sequence and the control's constructing and adding approach.

For your former problem, (postback event for sub controls not fire when the
composite control doesn't implement INamingContainer), this is because for
sub controls contained in composite control, they need to be assigned an
unique clientID which will be used when it's postback event be fired( the
runtime will use this ID to mapping the event to the correct control
instance). When we didn't implement NamingContainer interface, the
composite control won't assign the appropriate ClientID(also UniqueID) for
the nested sub controls, so sub controls' post back event won't be handled
correclty.

As for the new problem you mentioned, I'm wondering how did you create your
composite control (also its nested sub composite controls inside it)? For
the "Page" property, it'll be assigned properly when a certain control is
added into its container control's Controls collection, we don't need to
manually assign it. Anyway, would you try provide some code snippet to
represent your composite control's code logic? It'll be much helpful if you
can make a very simple repro demo control to demostrate the problem.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)






--------------------
| From: "TS" <[email protected]>
| References: <#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: processing postback
| Date: Tue, 2 Aug 2005 15:54:05 -0500
| Lines: 717
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups:
microsoft.public.dotnet.framework.aspnet.buildingcontrols,microsoft.public.d
otnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: 103nat100.tea.state.tx.us 198.214.103.100
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:10237
microsoft.public.dotnet.framework.aspnet.buildingcontrols:3976
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| I have a new issue:
|
| One of my controls in my composite control is in itself a composite
control.
| It has an event that is raised when one of its drop down lists selected
| index changes. In main composite control, i hook into this other control's
| event so that i can do processing. This event won't fire in either the
drop
| down list's selected index change event handler and also not in the event
| handler that my main control subscribes to.
|
| I have a clue that may be the reason: In this sub composite control, it
| tries to access the page property, which is null when it's
| CreateChildControls. So how i fixed it was to assign this composite
| control's page property to my main control's page property so that it now
| can access the page property. I'm wondering if this has something to do
with
| the event not firing.
|
| thanks
|
| | > I figured it out, i wasnt' implementing INamingContainer. that fixes
| > it...BUT WHY DOES THIS IMPACT IF EVENTS GET FIRED OR NOT????
| >
| >
| > | > > I think i maybe should be doing this at all because i can just access
| the
| > > control's value because that control handles the functionality
| > automatically
| > > that I was trying to do.
| > >
| > > If this is so, then i still have a problem: How do i raise events in
my
| > > control for controls i have created in createchildcontrols? I have the
| > > controls wired up to event handlers, but they are never hit.
| > >
| > > What do i need to do?
| > >
| > > thanks
| > >
| > > | > > > i followed the article at:
| > > >
| > >
| >
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
l/cpconpostbackdataprocessingsample.asp
| > > > and it works like that except like i said when I use
| createchildControls
| > > > instead of render (because i need to render multiple controls), it
| > doesn't
| > > > hit those postback methods.
| > > >
| > > > thanks again
| > > >
| > > > | > > > > Well i know it has something to do with the CREATEChildControls
| method
| > > > > because when i overrode render instead of doing that method at
all,
| > the
| > > > > LoadPostData() was executed. I guess it has something to do with
the
| > > > > controls being recreated each time, I DON"T KNOW.
| > > > >
| > > > > I need help all of you master coders :)
| > > > >
| > > > >
| > > > > | > > > > > i have a composite control that has dropdowns on them. The page
| will
| > > > post
| > > > > > back on change, but their events won't raise. Can anyone tell me
| > whats
| > > > > going
| > > > > > on? I tried to use the IPostBackDataHandler to try to get a hold
| of
| > > the
| > > > > > control to set values and such, but it has been no help. I'm
| > confused
| > > at
| > > > > how
| > > > > > this control is supposed to work. I want it to be self contained
| so
| > > that
| > > > > > when a control changes, it posts back and then reloads its
| dependent
| > > > drop
| > > > > > down lists with data that is filtered based on the value of the
| > > control
| > > > > that
| > > > > > changed.
| > > > > >
| > > > > > Every time the page posts back to server, the it hits the init
and
| > > load
| > > > > > events and createchildcontrols, but thats it. i can't get into
the
| > > > > > XXX_SelectedIndexChanged events for some reason even though they
| are
| > > > wired
| > > > > > to do so.
| > > > > >
| > > > > > Any help will be appreaciated as i'm starting to feel dumb.
| > > > > >
| > > > > > using System;
| > > > > >
| > > > > > using System.Collections.Specialized;
| > > > > >
| > > > > > using System.Web.UI;
| > > > > >
| > > > > > using System.Web.UI.WebControls;
| > > > > >
| > > > > > using System.Text;
| > > > > >
| > > > > > using Operations.Teams.Business;
| > > > > >
| > > > > > using Operations.Teams.Data;
| > > > > >
| > > > > > using Operations.Teams.Reporting;
| > > > > >
| > > > > > using Operations.Teams.Reporting.WebControls;
| > > > > >
| > > > > > namespace Operations.Teams.Web.ReportControls
| > > > > >
| > > > > > {
| > > > > >
| > > > > > /// <summary>
| > > > > >
| > > > > > /// Summary description for FiscalAgentHierarchy.
| > > > > >
| > > > > > /// </summary>
| > > > > >
| > > > > > public class FiscalAgentHierarchy : Control,
| > IReportParameterControl,
| > > > > > IPostBackDataHandler
| > > > > >
| > > > > > {
| > > > > >
| > > > > > public FiscalAgentHierarchy()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > Parameters.Add(new Parameter("@SchoolYear"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@ReportingGroup"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@FiscalAgentID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@FundingSourceID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@ProviderID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@SiteID"));
| > > > > >
| > > > > > Parameters.Add(new Parameter("@ClassID"));
| > > > > >
| > > > > > Parameters["@SchoolYear"].Value = 2006;
| > > > > >
| > > > > > }
| > > > > >
| > > > > >
| > > > > > #region Events
| > > > > >
| > > > > >
| > > > > > public bool LoadPostData(string postDataKey, NameValueCollection
| > > > postData)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > string postedValue = postData[postDataKey];
| > > > > >
| > > > > > return true;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > public void RaisePostDataChangedEvent()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > rysReportingYearSelector_ReportingYearChanged(this,
| > EventArgs.Empty);
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override void LoadViewState(object savedState)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > string zasdf="asdlfkjds";
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override object SaveViewState()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > string zsad="asdf";
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override void OnInit(EventArgs e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > //this.EnsureChildControls();
| > > > > >
| > > > > >
| > > > > > // Do whatever the control usually does OnInit
| > > > > >
| > > > > > base.OnInit(e);
| > > > > >
| > > > > > }
| > > > > >
| > > > > > protected override void OnLoad(EventArgs e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > //this.EnsureChildControls();
| > > > > >
| > > > > > // Do whatever the control usually does OnInit
| > > > > >
| > > > > > base.OnLoad(e);
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void
rysReportingYearSelector_ReportingYearChanged(object
| > > > sender,
| > > > > > EventArgs e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.LoadFundingSource();
| > > > > >
| > > > > > this.LoadProviders();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void fasFiscalAgent_FiscalAgentChanged(object sender,
| > > EventArgs
| > > > e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.LoadFundingSource();
| > > > > >
| > > > > > this.LoadProviders();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void ddlProviders_SelectedIndexChanged(object sender,
| > > EventArgs
| > > > e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > LoadSites();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void ddlSites_SelectedIndexChanged(object sender,
| EventArgs
| > e)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > LoadClasses();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > protected override void CreateChildControls()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > rysReportingYearSelector = new ReportingYearReportSelector();
| > > > > >
| > > > > > fasFiscalAgent = new FiscalAgentReportSelector();
| > > > > >
| > > > > > this.ddlFundingSource = new DropDownList();
| > > > > >
| > > > > > this.ddlProviders = new DropDownList();
| > > > > >
| > > > > > this.ddlSites = new DropDownList();
| > > > > >
| > > > > > this.ddlClasses = new DropDownList();
| > > > > >
| > > > > > rysReportingYearSelector.ID = ReportingYearSelectorControlId;
| > > > > >
| > > > > > fasFiscalAgent.ID = FiscalAgentSelectorControlId;
| > > > > >
| > > > > > ddlFundingSource.ID = FundingSourceControlId;
| > > > > >
| > > > > > ddlProviders.ID = ProvidersControlId;
| > > > > >
| > > > > > ddlSites.ID = SitesControlId;
| > > > > >
| > > > > > ddlClasses.ID = ClassesControlId;
| > > > > >
| > > > > > // Assign these controls' Page property because when they try to
| > > access
| > > > > Page
| > > > > > they get null reference - apparently they aren't in the control
| tree
| > > at
| > > > > that
| > > > > > point
| > > > > >
| > > > > > rysReportingYearSelector.Page = this.Page;
| > > > > >
| > > > > > fasFiscalAgent.Page = this.Page;
| > > > > >
| > > > > > rysReportingYearSelector.ReportingYearChanged += new
| > > > > > EventHandler(rysReportingYearSelector_ReportingYearChanged);
| > > > > >
| > > > > > fasFiscalAgent.FiscalAgentChanged += new
| > > > > > EventHandler(fasFiscalAgent_FiscalAgentChanged);
| > > > > >
| > > > > > ddlProviders.SelectedIndexChanged += new
| > > > > > EventHandler(ddlProviders_SelectedIndexChanged);
| > > > > >
| > > > > > ddlSites.SelectedIndexChanged += new
| > > > > > EventHandler(ddlSites_SelectedIndexChanged);
| > > > > >
| > > > > > fasFiscalAgent.IsSubmitOnChange = true;
| > > > > >
| > > > > > ddlProviders.AutoPostBack = true;
| > > > > >
| > > > > > ddlSites.AutoPostBack = true;
| > > > > >
| > > > > > // this.SchoolYear = rysReportingYearSelector.SchoolYear;
| > > > > >
| > > > > > // check if can populate funding sources and providers (because
| > > > > fiscalAgent
| > > > > > has been saved in session)
| > > > > >
| > > > > > if(this.fasFiscalAgent.SelectedFiscalAgentName != string.Empty)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > LoadFundingSource();
| > > > > >
| > > > > > LoadProviders();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlFundingSource.Visible = false;
| > > > > >
| > > > > > ddlProviders.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > // Initially set to false until their direct parent's selection
| has
| > > been
| > > > > > made (all other controls will have data on page load)
| > > > > >
| > > > > > ddlSites.Visible = false;
| > > > > >
| > > > > > ddlClasses.Visible = false;
| > > > > >
| > > > > > // start containing table
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table cellpadding=0
| > > > > > cellspacing=0><tr><td>"));
| > > > > >
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));
| > > > > >
| > > > > > this.Controls.Add(rysReportingYearSelector);
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));
| > > > > >
| > > > > > this.Controls.Add(fasFiscalAgent);
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > > Source</td><td>"));
| > > > > >
| > > > > > this.Controls.Add(ddlFundingSource);
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
| > > > >
| > > >
| > >
| >
|
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > > );
| > > > > >
| > > > > > this.Controls.Add(ddlProviders);
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
| > > >
| >
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Sites</td><td>"));
| > > > > >
| > > > > > this.Controls.Add(ddlSites);
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > >
| > > > >
| > > >
| > >
| >
|
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > > this.Controls.Add(ddlClasses);
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > > // end containing table
| > > > > >
| > > > > >
this.Controls.Add(WebHelper.MakeLiteral( said:
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadFundingSource()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > int fiscalAgentId = this.fasFiscalAgent.SelectedFiscalAgentId;
| > > > > >
| > > > > >
| > > > > > if(fiscalAgentId != int.MinValue)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.ddlFundingSource.Visible = true;
| > > > > >
| > > > > > this.ddlFundingSource.DataSource =
| > > > FiscalAgentFunding.Find(fiscalAgentId);
| > > > > >
| > > > > > this.ddlFundingSource.DataTextField = "ShortDescription";
| > > > > >
| > > > > > this.ddlFundingSource.DataValueField = "CodeId";
| > > > > >
| > > > > > this.ddlFundingSource.DataBind();
| > > > > >
| > > > > > if(this.ddlFundingSource.Items.Count > 1)
| > > > > >
| > > > > > this.ddlFundingSource.Items.Insert(0, new ListItem(string.Empty,
| > > > > > string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.ddlFundingSource.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadProviders()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > int fiscalAgentId = fasFiscalAgent.SelectedFiscalAgentId;
| > > > > >
| > > > > > if(fiscalAgentId != int.MinValue)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlProviders.Visible = true;
| > > > > >
| > > > > > ddlProviders.DataSource =
FiscalAgentProvider.Find(fiscalAgentId,
| > > > > > rysReportingYearSelector.ReportingYearStartDate,
| > > > > > rysReportingYearSelector.ReportingYearEndDate);
| > > > > >
| > > > > > ddlProviders.DataTextField = "ProviderName";
| > > > > >
| > > > > > ddlProviders.DataValueField = "ProviderId";
| > > > > >
| > > > > > ddlProviders.DataBind();
| > > > > >
| > > > > > ddlProviders.Items.Insert(0, new ListItem(string.Empty,
| > > string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > this.ddlProviders.Items.Clear();
| > > > > >
| > > > > > this.ddlProviders.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > LoadSites();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadSites()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > if(ddlProviders.SelectedValue != string.Empty)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > // Load the Site search parameters.
| > > > > >
| > > > > > SiteFindArgs siteFindArgs=new SiteFindArgs();
| > > > > >
| > > > > >
| > > > >
| > > >
| > >
| >
|
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
| > > > > > tId);
| > > > > >
| > > > > > ddlSites.Visible = true;
| > > > > >
| > > > > > ddlSites.DataSource = Business.Site.Find(siteFindArgs);
| > > > > >
| > > > > > ddlSites.DataTextField = "Name";
| > > > > >
| > > > > > ddlSites.DataValueField = "SiteId";
| > > > > >
| > > > > > ddlSites.DataBind();
| > > > > >
| > > > > > ddlSites.Items.Insert(0, new ListItem(string.Empty,
| string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlSites.Items.Clear();
| > > > > >
| > > > > > ddlSites.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > LoadClasses();
| > > > > >
| > > > > > }
| > > > > >
| > > > > > private void LoadClasses()
| > > > > >
| > > > > > {
| > > > > >
| > > > > > if(ddlSites.SelectedValue != string.Empty)
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();
| > > > > >
| > > > > > adultEdClassFindArgs.FiscalAgentId =
| > > > > > Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);
| > > > > >
| > > > > > adultEdClassFindArgs.ReportingYearStartDate =
| > > > > > rysReportingYearSelector.ReportingYearStartDate;
| > > > > >
| > > > > > adultEdClassFindArgs.ReportingYearEndDate =
| > > > > > rysReportingYearSelector.ReportingYearEndDate;
| > > > > >
| > > > > > adultEdClassFindArgs.ProviderName = ddlProviders.SelectedValue;
| > > > > >
| > > > > > adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;
| > > > > >
| > > > > >
| > > > > > ddlClasses.Visible = true;
| > > > > >
| > > > > > ddlClasses.DataSource = Class.Find(classFindArgs);
| > > > > >
| > > > > > ddlClasses.DataTextField = "Name";
| > > > > >
| > > > > > ddlClasses.DataValueField = "ClassId";
| > > > > >
| > > > > > ddlClasses.DataBind();
| > > > > >
| > > > > > ddlClasses.Items.Insert(0, new ListItem(string.Empty,
| > string.Empty));
| > > > > >
| > > > > > }
| > > > > >
| > > > > > else
| > > > > >
| > > > > > {
| > > > > >
| > > > > > ddlClasses.Items.Clear();
| > > > > >
| > > > > > ddlClasses.Visible = false;
| > > > > >
| > > > > > }
| > > > > >
| > > > > > }
| > > > > >
| > > > > >
| > > > > >
| > > > > > #region Public Properties
| > > > > >
| > > > > > #region IReportParameterControl Members
| > > > > >
| > > > > > public object ParameterValue
| > > > > >
| > > > > > {
| > > > > >
| > > > > > get{ return null; }
| > > > > >
| > > > > > set{ /*do nothing */ }
| > > > > >
| > > > > > }
| > > > > >
| > > > > > public ParameterCollection Parameters
| > > > > >
| > > > > > {
| > > > > >
| > > > > > get{ return parameters; }
| > > > > >
| > > > > > set{ parameters = value;}
| > > > > >
| > > > > > }
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > public int SchoolYear
| > > > > >
| > > > > > {
| > > > > >
| > > > > > get{ return (int) ViewState["SchoolYear"]; }
| > > > > >
| > > > > > set{ ViewState["SchoolYear"] = value; }
| > > > > >
| > > > > > }
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > #region Private Member Variables
| > > > > >
| > > > > > private ReportingYearReportSelector rysReportingYearSelector;
| > > > > >
| > > > > > private FiscalAgentReportSelector fasFiscalAgent;
| > > > > >
| > > > > > private DropDownList ddlFundingSource;
| > > > > >
| > > > > > private DropDownList ddlProviders;
| > > > > >
| > > > > > private DropDownList ddlSites;
| > > > > >
| > > > > > private DropDownList ddlClasses;
| > > > > >
| > > > > > private ParameterCollection parameters = new
| ParameterCollection();
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > #region Private Constants
| > > > > >
| > > > > > private const string ReportingYearSelectorControlId =
| > > > > > "rysReportingYearSelector";
| > > > > >
| > > > > > private const string FiscalAgentSelectorControlId =
| > > > > > "fasFiscalAgentSelector";
| > > > > >
| > > > > > private const string FundingSourceControlId =
"ddlFundingSource";
| > > > > >
| > > > > > private const string FundingSourceLabelControlId =
| > "lblFundingSource";
| > > > > >
| > > > > > private const string ProvidersControlId = "ddlProviders";
| > > > > >
| > > > > > private const string ProvidersLabelControlId = "lblProviders";
| > > > > >
| > > > > > private const string SitesControlId = "ddlSites";
| > > > > >
| > > > > > private const string SitesLabelControlId = "lblSites";
| > > > > >
| > > > > > private const string ClassesControlId = "ddlClasses";
| > > > > >
| > > > > > private const string ClassesLabelControlId = "lblClasses";
| > > > > >
| > > > > > #endregion
| > > > > >
| > > > > > }
| > > > > >
| > > > > > }
| > > > > >
| > > > > >
| > > > >
| > > > >
| > > >
| > > >
| > >
| > >
| >
| >
|
|
|
 
S

Steven Cheng[MSFT]

OK. I'll continue to followup in your "explanation of when need..." issue.
Please feel free to post there.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "TS" <[email protected]>
| References: <#[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: processing postback
| Date: Fri, 5 Aug 2005 08:34:54 -0500
| Lines: 848
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: 103nat100.tea.state.tx.us 198.214.103.100
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:4000
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| thanks, but it seems my only problem that still exists is the posts i'm
| making in "explanation of when need..."
|
|
| | > Hi TS,
| >
| > Welcome to ASPNET newsgroup.
| > Regarding on the post back event handling problem in composite control,
| > generaly speaking , the most likely cause is still the event handler's
| > registering sequence and the control's constructing and adding approach.
| >
| > For your former problem, (postback event for sub controls not fire when
| the
| > composite control doesn't implement INamingContainer), this is because
for
| > sub controls contained in composite control, they need to be assigned an
| > unique clientID which will be used when it's postback event be fired(
the
| > runtime will use this ID to mapping the event to the correct control
| > instance). When we didn't implement NamingContainer interface, the
| > composite control won't assign the appropriate ClientID(also UniqueID)
for
| > the nested sub controls, so sub controls' post back event won't be
handled
| > correclty.
| >
| > As for the new problem you mentioned, I'm wondering how did you create
| your
| > composite control (also its nested sub composite controls inside it)?
For
| > the "Page" property, it'll be assigned properly when a certain control
is
| > added into its container control's Controls collection, we don't need to
| > manually assign it. Anyway, would you try provide some code snippet to
| > represent your composite control's code logic? It'll be much helpful if
| you
| > can make a very simple repro demo control to demostrate the problem.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
| >
| > --------------------
| > | From: "TS" <[email protected]>
| > | References: <#[email protected]>
| > <[email protected]>
| > <[email protected]>
| > <[email protected]>
| > <[email protected]>
| > | Subject: Re: processing postback
| > | Date: Tue, 2 Aug 2005 15:54:05 -0500
| > | Lines: 717
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <[email protected]>
| > | Newsgroups:
| >
|
microsoft.public.dotnet.framework.aspnet.buildingcontrols,microsoft.public.d
| > otnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: 103nat100.tea.state.tx.us 198.214.103.100
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:10237
| > microsoft.public.dotnet.framework.aspnet.buildingcontrols:3976
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| > |
| > | I have a new issue:
| > |
| > | One of my controls in my composite control is in itself a composite
| > control.
| > | It has an event that is raised when one of its drop down lists
selected
| > | index changes. In main composite control, i hook into this other
| control's
| > | event so that i can do processing. This event won't fire in either the
| > drop
| > | down list's selected index change event handler and also not in the
| event
| > | handler that my main control subscribes to.
| > |
| > | I have a clue that may be the reason: In this sub composite control,
it
| > | tries to access the page property, which is null when it's
| > | CreateChildControls. So how i fixed it was to assign this composite
| > | control's page property to my main control's page property so that it
| now
| > | can access the page property. I'm wondering if this has something to
do
| > with
| > | the event not firing.
| > |
| > | thanks
| > |
| > | | > | > I figured it out, i wasnt' implementing INamingContainer. that fixes
| > | > it...BUT WHY DOES THIS IMPACT IF EVENTS GET FIRED OR NOT????
| > | >
| > | >
| > | > | > | > > I think i maybe should be doing this at all because i can just
| access
| > | the
| > | > > control's value because that control handles the functionality
| > | > automatically
| > | > > that I was trying to do.
| > | > >
| > | > > If this is so, then i still have a problem: How do i raise events
in
| > my
| > | > > control for controls i have created in createchildcontrols? I have
| the
| > | > > controls wired up to event handlers, but they are never hit.
| > | > >
| > | > > What do i need to do?
| > | > >
| > | > > thanks
| > | > >
| > | > > | > | > > > i followed the article at:
| > | > > >
| > | > >
| > | >
| > |
| >
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm
| > l/cpconpostbackdataprocessingsample.asp
| > | > > > and it works like that except like i said when I use
| > | createchildControls
| > | > > > instead of render (because i need to render multiple controls),
it
| > | > doesn't
| > | > > > hit those postback methods.
| > | > > >
| > | > > > thanks again
| > | > > >
| > | > > > | > | > > > > Well i know it has something to do with the
CREATEChildControls
| > | method
| > | > > > > because when i overrode render instead of doing that method at
| > all,
| > | > the
| > | > > > > LoadPostData() was executed. I guess it has something to do
with
| > the
| > | > > > > controls being recreated each time, I DON"T KNOW.
| > | > > > >
| > | > > > > I need help all of you master coders :)
| > | > > > >
| > | > > > >
| > | > > > > | > | > > > > > i have a composite control that has dropdowns on them. The
| page
| > | will
| > | > > > post
| > | > > > > > back on change, but their events won't raise. Can anyone
tell
| me
| > | > whats
| > | > > > > going
| > | > > > > > on? I tried to use the IPostBackDataHandler to try to get a
| hold
| > | of
| > | > > the
| > | > > > > > control to set values and such, but it has been no help. I'm
| > | > confused
| > | > > at
| > | > > > > how
| > | > > > > > this control is supposed to work. I want it to be self
| contained
| > | so
| > | > > that
| > | > > > > > when a control changes, it posts back and then reloads its
| > | dependent
| > | > > > drop
| > | > > > > > down lists with data that is filtered based on the value of
| the
| > | > > control
| > | > > > > that
| > | > > > > > changed.
| > | > > > > >
| > | > > > > > Every time the page posts back to server, the it hits the
init
| > and
| > | > > load
| > | > > > > > events and createchildcontrols, but thats it. i can't get
into
| > the
| > | > > > > > XXX_SelectedIndexChanged events for some reason even though
| they
| > | are
| > | > > > wired
| > | > > > > > to do so.
| > | > > > > >
| > | > > > > > Any help will be appreaciated as i'm starting to feel dumb.
| > | > > > > >
| > | > > > > > using System;
| > | > > > > >
| > | > > > > > using System.Collections.Specialized;
| > | > > > > >
| > | > > > > > using System.Web.UI;
| > | > > > > >
| > | > > > > > using System.Web.UI.WebControls;
| > | > > > > >
| > | > > > > > using System.Text;
| > | > > > > >
| > | > > > > > using Operations.Teams.Business;
| > | > > > > >
| > | > > > > > using Operations.Teams.Data;
| > | > > > > >
| > | > > > > > using Operations.Teams.Reporting;
| > | > > > > >
| > | > > > > > using Operations.Teams.Reporting.WebControls;
| > | > > > > >
| > | > > > > > namespace Operations.Teams.Web.ReportControls
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > /// <summary>
| > | > > > > >
| > | > > > > > /// Summary description for FiscalAgentHierarchy.
| > | > > > > >
| > | > > > > > /// </summary>
| > | > > > > >
| > | > > > > > public class FiscalAgentHierarchy : Control,
| > | > IReportParameterControl,
| > | > > > > > IPostBackDataHandler
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > public FiscalAgentHierarchy()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@SchoolYear"));
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@ReportingGroup"));
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@FiscalAgentID"));
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@FundingSourceID"));
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@ProviderID"));
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@SiteID"));
| > | > > > > >
| > | > > > > > Parameters.Add(new Parameter("@ClassID"));
| > | > > > > >
| > | > > > > > Parameters["@SchoolYear"].Value = 2006;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > >
| > | > > > > > #region Events
| > | > > > > >
| > | > > > > >
| > | > > > > > public bool LoadPostData(string postDataKey,
| NameValueCollection
| > | > > > postData)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > string postedValue = postData[postDataKey];
| > | > > > > >
| > | > > > > > return true;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > public void RaisePostDataChangedEvent()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > rysReportingYearSelector_ReportingYearChanged(this,
| > | > EventArgs.Empty);
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > protected override void LoadViewState(object savedState)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > string zasdf="asdlfkjds";
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > protected override object SaveViewState()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > string zsad="asdf";
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > protected override void OnInit(EventArgs e)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > //this.EnsureChildControls();
| > | > > > > >
| > | > > > > >
| > | > > > > > // Do whatever the control usually does OnInit
| > | > > > > >
| > | > > > > > base.OnInit(e);
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > protected override void OnLoad(EventArgs e)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > //this.EnsureChildControls();
| > | > > > > >
| > | > > > > > // Do whatever the control usually does OnInit
| > | > > > > >
| > | > > > > > base.OnLoad(e);
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void
| > rysReportingYearSelector_ReportingYearChanged(object
| > | > > > sender,
| > | > > > > > EventArgs e)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > this.LoadFundingSource();
| > | > > > > >
| > | > > > > > this.LoadProviders();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void fasFiscalAgent_FiscalAgentChanged(object
sender,
| > | > > EventArgs
| > | > > > e)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > this.LoadFundingSource();
| > | > > > > >
| > | > > > > > this.LoadProviders();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void ddlProviders_SelectedIndexChanged(object
sender,
| > | > > EventArgs
| > | > > > e)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > LoadSites();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void ddlSites_SelectedIndexChanged(object sender,
| > | EventArgs
| > | > e)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > LoadClasses();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > #endregion
| > | > > > > >
| > | > > > > > protected override void CreateChildControls()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > rysReportingYearSelector = new
ReportingYearReportSelector();
| > | > > > > >
| > | > > > > > fasFiscalAgent = new FiscalAgentReportSelector();
| > | > > > > >
| > | > > > > > this.ddlFundingSource = new DropDownList();
| > | > > > > >
| > | > > > > > this.ddlProviders = new DropDownList();
| > | > > > > >
| > | > > > > > this.ddlSites = new DropDownList();
| > | > > > > >
| > | > > > > > this.ddlClasses = new DropDownList();
| > | > > > > >
| > | > > > > > rysReportingYearSelector.ID =
ReportingYearSelectorControlId;
| > | > > > > >
| > | > > > > > fasFiscalAgent.ID = FiscalAgentSelectorControlId;
| > | > > > > >
| > | > > > > > ddlFundingSource.ID = FundingSourceControlId;
| > | > > > > >
| > | > > > > > ddlProviders.ID = ProvidersControlId;
| > | > > > > >
| > | > > > > > ddlSites.ID = SitesControlId;
| > | > > > > >
| > | > > > > > ddlClasses.ID = ClassesControlId;
| > | > > > > >
| > | > > > > > // Assign these controls' Page property because when they
try
| to
| > | > > access
| > | > > > > Page
| > | > > > > > they get null reference - apparently they aren't in the
| control
| > | tree
| > | > > at
| > | > > > > that
| > | > > > > > point
| > | > > > > >
| > | > > > > > rysReportingYearSelector.Page = this.Page;
| > | > > > > >
| > | > > > > > fasFiscalAgent.Page = this.Page;
| > | > > > > >
| > | > > > > > rysReportingYearSelector.ReportingYearChanged += new
| > | > > > > > EventHandler(rysReportingYearSelector_ReportingYearChanged);
| > | > > > > >
| > | > > > > > fasFiscalAgent.FiscalAgentChanged += new
| > | > > > > > EventHandler(fasFiscalAgent_FiscalAgentChanged);
| > | > > > > >
| > | > > > > > ddlProviders.SelectedIndexChanged += new
| > | > > > > > EventHandler(ddlProviders_SelectedIndexChanged);
| > | > > > > >
| > | > > > > > ddlSites.SelectedIndexChanged += new
| > | > > > > > EventHandler(ddlSites_SelectedIndexChanged);
| > | > > > > >
| > | > > > > > fasFiscalAgent.IsSubmitOnChange = true;
| > | > > > > >
| > | > > > > > ddlProviders.AutoPostBack = true;
| > | > > > > >
| > | > > > > > ddlSites.AutoPostBack = true;
| > | > > > > >
| > | > > > > > // this.SchoolYear = rysReportingYearSelector.SchoolYear;
| > | > > > > >
| > | > > > > > // check if can populate funding sources and providers
| (because
| > | > > > > fiscalAgent
| > | > > > > > has been saved in session)
| > | > > > > >
| > | > > > > > if(this.fasFiscalAgent.SelectedFiscalAgentName !=
| string.Empty)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > LoadFundingSource();
| > | > > > > >
| > | > > > > > LoadProviders();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > else
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > ddlFundingSource.Visible = false;
| > | > > > > >
| > | > > > > > ddlProviders.Visible = false;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > // Initially set to false until their direct parent's
| selection
| > | has
| > | > > been
| > | > > > > > made (all other controls will have data on page load)
| > | > > > > >
| > | > > > > > ddlSites.Visible = false;
| > | > > > > >
| > | > > > > > ddlClasses.Visible = false;
| > | > > > > >
| > | > > > > > // start containing table
| > | > > > > >
| > | > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table
cellpadding=0
| > | > > > > > cellspacing=0><tr><td>"));
| > | > > > > >
| > | > > > > >
| > | > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));
| > | > > > > >
| > | > > > > > this.Controls.Add(rysReportingYearSelector);
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > | > > > > >
| > | > > > > > this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>"));
| > | > > > > >
| > | > > > > > this.Controls.Add(fasFiscalAgent);
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Funding
| > | > > > > > Source</td><td>"));
| > | > > > > >
| > | > > > > > this.Controls.Add(ddlFundingSource);
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > | > > > > >
| > | > > > > >
| > | > > > >
| > | > > >
| > | > >
| > | >
| > |
| >
|
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Providers</td><td>")
| > | > > > > > );
| > | > > > > >
| > | > > > > > this.Controls.Add(ddlProviders);
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > | > > > > >
| > | > > > > >
| > | > > >
| > | >
| >
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Sites</td><td>"));
| > | > > > > >
| > | > > > > > this.Controls.Add(ddlSites);
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr><tr><td>"));
| > | > > > > >
| > | > > > > >
| > | > > > >
| > | > > >
| > | > >
| > | >
| > |
| >
|
this.Controls.Add(WebHelper.MakeLiteral("<table><tr><td>Classes</td><td>"));
| > | > > > > >
| > | > > > > > this.Controls.Add(ddlClasses);
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > > // end containing table
| > | > > > > >
| > | > > > > >
| this.Controls.Add(WebHelper.MakeLiteral("</td></tr></table>"));
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void LoadFundingSource()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > int fiscalAgentId =
this.fasFiscalAgent.SelectedFiscalAgentId;
| > | > > > > >
| > | > > > > >
| > | > > > > > if(fiscalAgentId != int.MinValue)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > this.ddlFundingSource.Visible = true;
| > | > > > > >
| > | > > > > > this.ddlFundingSource.DataSource =
| > | > > > FiscalAgentFunding.Find(fiscalAgentId);
| > | > > > > >
| > | > > > > > this.ddlFundingSource.DataTextField = "ShortDescription";
| > | > > > > >
| > | > > > > > this.ddlFundingSource.DataValueField = "CodeId";
| > | > > > > >
| > | > > > > > this.ddlFundingSource.DataBind();
| > | > > > > >
| > | > > > > > if(this.ddlFundingSource.Items.Count > 1)
| > | > > > > >
| > | > > > > > this.ddlFundingSource.Items.Insert(0, new
| ListItem(string.Empty,
| > | > > > > > string.Empty));
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > else
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > this.ddlFundingSource.Visible = false;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void LoadProviders()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > int fiscalAgentId = fasFiscalAgent.SelectedFiscalAgentId;
| > | > > > > >
| > | > > > > > if(fiscalAgentId != int.MinValue)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > ddlProviders.Visible = true;
| > | > > > > >
| > | > > > > > ddlProviders.DataSource =
| > FiscalAgentProvider.Find(fiscalAgentId,
| > | > > > > > rysReportingYearSelector.ReportingYearStartDate,
| > | > > > > > rysReportingYearSelector.ReportingYearEndDate);
| > | > > > > >
| > | > > > > > ddlProviders.DataTextField = "ProviderName";
| > | > > > > >
| > | > > > > > ddlProviders.DataValueField = "ProviderId";
| > | > > > > >
| > | > > > > > ddlProviders.DataBind();
| > | > > > > >
| > | > > > > > ddlProviders.Items.Insert(0, new ListItem(string.Empty,
| > | > > string.Empty));
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > else
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > this.ddlProviders.Items.Clear();
| > | > > > > >
| > | > > > > > this.ddlProviders.Visible = false;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > LoadSites();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void LoadSites()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > if(ddlProviders.SelectedValue != string.Empty)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > // Load the Site search parameters.
| > | > > > > >
| > | > > > > > SiteFindArgs siteFindArgs=new SiteFindArgs();
| > | > > > > >
| > | > > > > >
| > | > > > >
| > | > > >
| > | > >
| > | >
| > |
| >
|
siteFindArgs.FiscalAgentId=Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgen
| > | > > > > > tId);
| > | > > > > >
| > | > > > > > ddlSites.Visible = true;
| > | > > > > >
| > | > > > > > ddlSites.DataSource = Business.Site.Find(siteFindArgs);
| > | > > > > >
| > | > > > > > ddlSites.DataTextField = "Name";
| > | > > > > >
| > | > > > > > ddlSites.DataValueField = "SiteId";
| > | > > > > >
| > | > > > > > ddlSites.DataBind();
| > | > > > > >
| > | > > > > > ddlSites.Items.Insert(0, new ListItem(string.Empty,
| > | string.Empty));
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > else
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > ddlSites.Items.Clear();
| > | > > > > >
| > | > > > > > ddlSites.Visible = false;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > LoadClasses();
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > private void LoadClasses()
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > if(ddlSites.SelectedValue != string.Empty)
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > ClassFindArgs adultEdClassFindArgs = new ClassFindArgs();
| > | > > > > >
| > | > > > > > adultEdClassFindArgs.FiscalAgentId =
| > | > > > > > Convert.ToInt32(fasFiscalAgent.SelectedFiscalAgentId);
| > | > > > > >
| > | > > > > > adultEdClassFindArgs.ReportingYearStartDate =
| > | > > > > > rysReportingYearSelector.ReportingYearStartDate;
| > | > > > > >
| > | > > > > > adultEdClassFindArgs.ReportingYearEndDate =
| > | > > > > > rysReportingYearSelector.ReportingYearEndDate;
| > | > > > > >
| > | > > > > > adultEdClassFindArgs.ProviderName =
| ddlProviders.SelectedValue;
| > | > > > > >
| > | > > > > > adultEdClassFindArgs.SiteName = ddlSites.SelectedValue;
| > | > > > > >
| > | > > > > >
| > | > > > > > ddlClasses.Visible = true;
| > | > > > > >
| > | > > > > > ddlClasses.DataSource = Class.Find(classFindArgs);
| > | > > > > >
| > | > > > > > ddlClasses.DataTextField = "Name";
| > | > > > > >
| > | > > > > > ddlClasses.DataValueField = "ClassId";
| > | > > > > >
| > | > > > > > ddlClasses.DataBind();
| > | > > > > >
| > | > > > > > ddlClasses.Items.Insert(0, new ListItem(string.Empty,
| > | > string.Empty));
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > else
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > ddlClasses.Items.Clear();
| > | > > > > >
| > | > > > > > ddlClasses.Visible = false;
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > >
| > | > > > > >
| > | > > > > > #region Public Properties
| > | > > > > >
| > | > > > > > #region IReportParameterControl Members
| > | > > > > >
| > | > > > > > public object ParameterValue
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > get{ return null; }
| > | > > > > >
| > | > > > > > set{ /*do nothing */ }
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > public ParameterCollection Parameters
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > get{ return parameters; }
| > | > > > > >
| > | > > > > > set{ parameters = value;}
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > #endregion
| > | > > > > >
| > | > > > > > public int SchoolYear
| > | > > > > >
| > | > > > > > {
| > | > > > > >
| > | > > > > > get{ return (int) ViewState["SchoolYear"]; }
| > | > > > > >
| > | > > > > > set{ ViewState["SchoolYear"] = value; }
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > #endregion
| > | > > > > >
| > | > > > > > #region Private Member Variables
| > | > > > > >
| > | > > > > > private ReportingYearReportSelector
rysReportingYearSelector;
| > | > > > > >
| > | > > > > > private FiscalAgentReportSelector fasFiscalAgent;
| > | > > > > >
| > | > > > > > private DropDownList ddlFundingSource;
| > | > > > > >
| > | > > > > > private DropDownList ddlProviders;
| > | > > > > >
| > | > > > > > private DropDownList ddlSites;
| > | > > > > >
| > | > > > > > private DropDownList ddlClasses;
| > | > > > > >
| > | > > > > > private ParameterCollection parameters = new
| > | ParameterCollection();
| > | > > > > >
| > | > > > > > #endregion
| > | > > > > >
| > | > > > > > #region Private Constants
| > | > > > > >
| > | > > > > > private const string ReportingYearSelectorControlId =
| > | > > > > > "rysReportingYearSelector";
| > | > > > > >
| > | > > > > > private const string FiscalAgentSelectorControlId =
| > | > > > > > "fasFiscalAgentSelector";
| > | > > > > >
| > | > > > > > private const string FundingSourceControlId =
| > "ddlFundingSource";
| > | > > > > >
| > | > > > > > private const string FundingSourceLabelControlId =
| > | > "lblFundingSource";
| > | > > > > >
| > | > > > > > private const string ProvidersControlId = "ddlProviders";
| > | > > > > >
| > | > > > > > private const string ProvidersLabelControlId =
"lblProviders";
| > | > > > > >
| > | > > > > > private const string SitesControlId = "ddlSites";
| > | > > > > >
| > | > > > > > private const string SitesLabelControlId = "lblSites";
| > | > > > > >
| > | > > > > > private const string ClassesControlId = "ddlClasses";
| > | > > > > >
| > | > > > > > private const string ClassesLabelControlId = "lblClasses";
| > | > > > > >
| > | > > > > > #endregion
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > > }
| > | > > > > >
| > | > > > > >
| > | > > > >
| > | > > > >
| > | > > >
| > | > > >
| > | > >
| > | > >
| > | >
| > | >
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top