Oct 06
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PopUpRadioList.aspx.cs" Inherits="PopUpRadioList" %> <%@ Register TagPrefix="ajaxToolkit" Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <style type="text/css"> .popupControl { background-color:White; position:absolute; visibility:hidden; } </style> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:DetailsView ID="dvProduct" runat="server" DefaultMode="Edit" AutoGenerateRows="false" Width="100%" HeaderText="Products"> <HeaderStyle BackColor="AliceBlue" Font-Bold="true" /> <FieldHeaderStyle BackColor="aliceBlue" Width="150px" Font-Bold="true" /> <RowStyle Height="20px" /> <Fields> <asp:BoundField HeaderText="Column1" DataField="Column1" /> <asp:BoundField HeaderText="Column2" DataField="Column2" /> <asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:TextBox ID="txtCategory" runat="server" Text='<%# Eval("Column2") %>' /> <asp:Panel ID="pnlCategories" runat="server" CssClass="popupControl"> <div style="border: 1px outset white; width: 275px"> <asp:UpdatePanel ID="Update1" runat="server"> <ContentTemplate> <div> <asp:RadioButtonList ID="rdoButton" runat="server" DataSource='<%#GetCustomMadeDataTable()%>' DataTextField="Column1" DataValueField="Id" AutoPostBack="True" SelectedValue='<%# Bind("Id") %>' OnSelectedIndexChanged="rdoButton_SelectedIndexChanged"> </asp:RadioButtonList> </div> </ContentTemplate> </asp:UpdatePanel> </div> <ajaxToolkit:PopupControlExtender ID="popupControl" runat="server" TargetControlID="txtCategory" PopupControlID="pnlCategories" CommitProperty="value" Position="Top"> </ajaxToolkit:PopupControlExtender> </asp:Panel> </ItemTemplate> </asp:TemplateField> </Fields> </asp:DetailsView> </form> </body> </html>
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using AjaxControlToolkit; public partial class PopUpRadioList : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["strTemp"] != null) { dvProduct.DataSource = Session["strTemp"] as DataTable; dvProduct.DataBind(); } else { dvProduct.DataSource = GetCustomMadeDataTable(); dvProduct.DataBind(); } } } public DataTable GetCustomMadeDataTable() { //Create a new DataTable object System.Data.DataTable objDataTable = new System.Data.DataTable(); //Create three columns with string as their type objDataTable.Columns.Add("Id", typeof(string)); objDataTable.Columns.Add("Column1", typeof(string)); objDataTable.Columns.Add("Column2", typeof(string)); objDataTable.Columns.Add("Column3", typeof(string)); //Adding some data in the rows of this DataTable DataRow dr; for (int i = 0; i <= 5; i++) { dr = objDataTable.NewRow(); dr[0] = i.ToString(); dr[1] = "Column1Data" + i.ToString(); dr[2] = "Column2Data" + i.ToString(); dr[3] = "Column3Data" + i.ToString(); objDataTable.Rows.Add(dr); } DataColumn[] dcPk = new DataColumn[1]; dcPk[0] = objDataTable.Columns["Id"]; objDataTable.PrimaryKey = dcPk; Session["strTemp"] = objDataTable; return objDataTable; } protected void rdoButton_SelectedIndexChanged(object sender, EventArgs e) { RadioButtonList rdoButtons = (RadioButtonList)sender; PopupControlExtender popupControl = (PopupControlExtender)rdoButtons.NamingContainer.FindControl("popupControl"); // Popup result is the selected category popupControl.Commit(rdoButtons.SelectedItem.Text); } }