I'm building a page that has the following controls: one modalpopupextender and two Accordion sections. The top accordion is populated on the loading of the page. It it is used to contain several CheckBoxLists that I use for filtering the data in Accordion #2.
if (!IsPostBack)
{
DataSet ds = jdh.GetDataSetFromDB("Select GeoLocationID, GeoLocationName from geolocation order by GeoLocationName");
Locationschklst.DataSource = ds;
Locationschklst.DataTextField = "GeoLocationName";
Locationschklst.DataValueField = "GeoLocationID";
Locationschklst.DataBind();
DataSet ds1 = jdh.GetDataSetFromDB("Select PostingTypeID, PostingTypeName from PostingType where PostingTypeID >= 3 and PostingTypeID <= 10 order by PostingTypeID");
OpportunityChklst.DataSource = ds1;
OpportunityChklst.DataTextField = "PostingTypeName";
OpportunityChklst.DataValueField = "PostingTypeID";
OpportunityChklst.DataBind();
DataSet ds2 = jdh.GetDataSetFromDB("Select SalaryGradeID, SalaryGrade from SalaryGrade order by SalaryGradeID");
SalaryGradeChklst.DataSource = ds2;
SalaryGradeChklst.DataTextField = "SalaryGrade";
SalaryGradeChklst.DataValueField = "SalaryGradeID";
SalaryGradeChklst.DataBind();
DataSet ds3 = jdh.GetDataSetFromDB("Select LOBMFOID, LOBMFOAbb from LOBMFO order by LOBMFOAbb");
DisciplineChklst.DataSource = ds3;
DisciplineChklst.DataTextField = "LOBMFOAbb";
DisciplineChklst.DataValueField = "LOBMFOID";
DisciplineChklst.DataBind();
VirtualChklst.Items.Add("No");
VirtualChklst.Items.Add("Yes");
//LoadOpportunities("EXEC GetOpenPostings");
}The second accordion is populated dynamically on page load. It occurs regardless of whether the load is a postback or not. I did this because if I put it in the !postback section, it doesn't display when I select filters in the first accordion. It creates the panels dynamically based on the results of the returned dataset. Each panel that gets created has a button.
protected void LoadOpportunities(string query)
{
DataSet openOpportunities_ds = jdh.GetDataSetFromDB(query);
int i = 0; // I will use this for creating unique accordion panes in each iteration of the loop
Label lblTitle; // This i will use as a child control to handle Header Text in the accordion pane
Label lblContent; // This i will use as a child control to handle Content Text in the accordion pane
UpdatePanel updpnl;
AjaxControlToolkit.AccordionPane pn; // I have declared an accordion pane but not yet initialized
foreach (DataRow dr in openOpportunities_ds.Tables[0].Rows)
{
// Begin your table
StringBuilder sb = new StringBuilder("<table>");
sb.AppendFormat("<tr><td style=\"width:150px;\"></td><td style=\"width:750px;\"></td></tr>");
sb.AppendFormat("<tr><td style=\"background-color:Yellow; font-weight:bold; text-align:right;border:solid\">{0}</td><td style=\"font-size:18px\">{1}</td></tr>", "Location:", dr["GeoLocationName"].ToString());
sb.AppendFormat("<tr><td style=\"background-color:Yellow; font-weight:bold; text-align:right;border:solid\">{0}</td><td style=\"font-size:18px\">{1}</td></tr>", "Salary Grade:", dr["SalaryGrade"].ToString());
lblTitle = new Label();
lblContent = new Label();
updpnl = new UpdatePanel();
lblTitle.Text = "ID: <b>" + dr["PostingID"].ToString() + "</b> Title: <b>" + dr["PostingTitle"].ToString() + "</b> Discipline: <b>" + dr["LOBMFOAbb"].ToString() +"</b> Virtual: <b>" + dr["VirtualPosition"].ToString() + "</b> Opportunity Type: <b>" + dr["PostingTypeName"].ToString() + "</b>";
Button ApplyButton = new Button();
ApplyButton.ID = "Apply_" + dr["PostingID"].ToString();
ApplyButton.Text = "Apply";
ApplyButton.Click += new EventHandler(this.ApplyOpportunity);
updpnl.ContentTemplateContainer.Controls.Add(ApplyButton);
lblContent.Text = sb.ToString();
pn = new AjaxControlToolkit.AccordionPane();
pn.ID = "Pane" + dr["PostingID"].ToString();
pn.HeaderContainer.Controls.Add(lblTitle);
pn.ContentContainer.Controls.Add(lblContent);
pn.ContentContainer.Controls.Add(updpnl);
//Accordion1.Panes.Remove(pn);
Accordion1.Panes.Add(pn);++i;
}
}Up to this point everything works fine. The issue I have is the following: When the user presses the button in the panel the modalpopupextender is supposed to be populated with data from the panel that contained the button. I can get the data I need in the code behind, but when the popup displays it is not getting populated.
protected void modalpopupdisplay(string OpID)
{
int i = OpID.IndexOf("_");
string opportunityid = OpID.Substring(i+1,OpID.Length - (i+1));
string title = jdh.GetSingleValueFromDB("Select PostingTitle from postings where PostingID = '" + opportunityid + "'");
title = "Apply to " + title;
TheHeader.Text = title;
ModalPopupExtender1.Show();
//Page.ClientScript.RegisterClientScriptBlock(GetType(), "scrollTop", "function scrollTop(){ window.scrollTo(0,0);} window.onload=scrollTop;", true);
}In the above code I can succesfully build the "title" string and assign it to the "TheHeader.Text". However when the popup displays, TheHeader.Text is empty.
<asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton> <ajaxToolkit:modalpopupextender id="ModalPopupExtender1" runat="server"
okcontrolid="btnOkay"
targetcontrolid="lnkDummy"
popupcontrolid="Panel1"
BehaviorID="mpe"
backgroundcssclass="ModalPopupBG"></ajaxToolkit:modalpopupextender><asp:panel id="Panel1" style="display: none" runat="server" CssClass="modalPopup"><div class="PopupHeader" id="PopupHeader"><asp:Literal runat="server" Id="TheHeader"></asp:Literal></div><div class="PopupBody"> <input id="btnOkay" type="button" value="OK" /></div> </asp:panel>I'm guessing this has to do with postbacks and such, but I'm not sure how to configure this so the accordions work as they should other than how I did them.