Using a RadioButtonList to select choices for entering data, one of which is a gridview that is in a AJAX ModalPopUp. When user clicks button in the ModalPopUp the ModalPopUp needs to hide. That does not work at this point although it was at one point. Code appears below. Thinking it is something simple I am overlooking but have reviewed a lot of other posts without success:
RadioButtonList:
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Selected="True">Manual Entry (separate with semi-colons)</asp:ListItem>
<asp:ListItem>Artists Only</asp:ListItem>
<asp:ListItem>Clients Only</asp:ListItem>
<asp:ListItem>Test with a gridview</asp:ListItem>
</asp:RadioButtonList>
Gridview in ModalPopUp:
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:HiddenField runat="server" ID="ModalHidden" />
<ajax:ModalPopupExtender ID="George" runat="server" TargetControlID="ModalHidden" PopupControlID="PopUpPanel" DropShadow="true" CancelControlID="btnCancel" PopupDragHandleControlID="Select Emails" Drag="true">
</ajax:ModalPopupExtender>
<br>
</br>
<br>
</br>
<asp:Panel ID="PopUpPanel" runat="server" BorderColor="Black" BackColor="LightGray" BorderStyle="Solid" BorderWidth="10px">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource3">
<rowstyle backcolor="LightCyan" forecolor="DarkBlue" font-italic="true"/>
<alternatingrowstyle backcolor="PaleTurquoise" forecolor="DarkBlue" font-italic="true"/>
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="ckboxGridview" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" Visible="false"/>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" />
<asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" SortExpression="EmailAddress" />
</Columns>
</asp:GridView>
<br>
</br>
<asp:Button ID="btnSelectGVAddresses" runat="server" Text="Select Addresses" OnClick="btnOK_Click" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:C:\........ %>" SelectCommand="SELECT * FROM [tbl_Op_Recipients]"></asp:SqlDataSource>
</asp:Panel>
<br>
</br>
</ContentTemplate>
</asp:UpdatePanel>
Code Behind for RadioButtonList:
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
TextBox temp_sent = frmSendEmail.FindControl("sent_toTextBox") as TextBox;
RadioButtonList temp_radio = frmSendEmail.FindControl("RadioButtonList1")
as RadioButtonList;
if (temp_radio.SelectedItem.Text == "Artists Only")
{
temp_sent.Text = "All Artists";
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = false;
frmSendEmail.FindControl("PopUpPanel").Visible = false;
string sqlquery = @"SELECT EmailAddress, ISNULL(FirstName, 'Artist') AS EmailName FROM tbl_Op_Recipients WHERE EmailAddress IS NOT NULL AND UserType = 'A'";
gather_emails(sqlquery);
}
if (temp_radio.SelectedItem.Text == "Clients Only")
{
temp_sent.Text = "All Clients";
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = false;
frmSendEmail.FindControl("PopUpPanel").Visible = false;
string sqlquery = @"SELECT EmailAddress, ISNULL(FirstName, 'Client') AS EmailName FROM tbl_Op_Recipients WHERE EmailAddress IS NOT NULL AND UserType = 'C'";
gather_emails(sqlquery);
}
if (temp_radio.SelectedItem.Text == "Manual Entry (separate with semi-colons)")
{
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = true;
temp_sent.Text = "Enter Names and Emails Manually";
frmSendEmail.FindControl("PopUpPanel").Visible = false;
}
if (temp_radio.SelectedItem.Text == "Test with a gridview")
{
temp_sent.Text = "Select multiple items from popup";
frmSendEmail.FindControl("EmailAddressesForEmail").Visible = false;
frmSendEmail.FindControl("PopUpPanel").Visible = true;
ModalPopupExtender test = frmSendEmail.FindControl("George") as ModalPopupExtender;
test.Show();
Response.Write("breakpoint 291");
}
if (temp_radio.SelectedItem.Text == null )
temp_radio.Text = "";
}
Code behind for Gridview (hide modalpopup):
protected void btnOK_Click(object sender, EventArgs e)
{
Panel PanelTemp = frmSendEmail.FindControl("PopUpPanel") as Panel;
PanelTemp.Visible = false;
RadioButtonList tempRadioButton = frmSendEmail.FindControl("RadioButtonList1") as RadioButtonList;
tempRadioButton.Items[0].Selected = true;
ModalPopupExtender PopUpTemp = frmSendEmail.FindControl("George") as ModalPopupExtender;
PopUpTemp.Hide();
GridView GVTemp = frmSendEmail.FindControl("Gridview1") as GridView;
var list = new List<EmailAddresses>();
foreach(GridViewRow row in GVTemp.Rows)
{
CheckBox ChkBoxtmp = row.FindControl("ckboxGridview") as CheckBox;
if(ChkBoxtmp.Checked)
{
list.Add(new EmailAddresses { EmailAddress = row.Cells[4].Text, FirstNames = row.Cells[2].Text });
}
}
EmailAddresses[] allRecords = list.ToArray();
btnSend_Click(allRecords);
}