Modal Popup from Repeater

ASP.NET The repeater is data-bound list control that allows custom layout by repeating a specified template for each item displayed in the list. It is more similar to ASP.NET GridView power, but it will enable complete control.
In this post, I will show you how to open a Modal popup from the repeater. The code is straightforward and easy to understand.

<%@ Page Language="C#" AutoEventWireup="true"  
 Inherits="RepeaterModalPopup" %>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
<html xmlns="">  
<head runat="server">  
 <title>Untitled Page</title>  
 <script type="text/jscript">  
  function ShowModalWindow(Id)  
window.showModalDialog("Details.aspx?accountNo="+ Id +"","",  
 <form id="form1" runat="server">  
         <asp:Repeater ID="Repeater1" runat="server">  
                 <table border="1" width="100%">  
                         <a href='Details.aspx?FrromTest=true  
&accountno=<%# DataBinder.Eval(Container.DataItem,"accountNo")  
%>&TypeDesc=<%# DataBinder.Eval(Container.DataItem,"CompanyName") %>'>  
                             <%# DataBinder.Eval(Container.DataItem, "CompanyName")%>  
                         <a href='#'  
onclick="ShowModalWindow('<%# DataBinder.Eval(Container.DataItem,"accountNo") %>');">  
                             <%# DataBinder.Eval(Container.DataItem, "CompanyName")%>  
                         <%# DataBinder.Eval(Container.DataItem,"Address") %>  
                         This is a free column</td>  

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;  

public partial class RepeaterModalPopup : System.Web.UI.Page  
 protected void Page_Load(object sender, EventArgs e)  

     Repeater1.DataSource = GetDataSet();  
 public DataSet GetDataSet()  
     DataSet ds = new DataSet();  
     DataTable dt = new DataTable("Company");  
     DataRow dr;  
     dt.Columns.Add(new DataColumn("accountNo", typeof(Int32)));  
     dt.Columns.Add(new DataColumn("CompanyName", typeof(string)));  
     dt.Columns.Add(new DataColumn("Address", typeof(string)));  
     for (int i = 0; i <= 10; i++)  
         dr = dt.NewRow();  
         dr[0] = i;  
         dr[1] = "Company" + i + Environment.NewLine + "Title" + i;  
         dr[2] = "Address" + i + Environment.NewLine + "Title" + i;  
     return ds;  


public partial class Details : System.Web.UI.Page  
 protected void Page_Load(object sender, EventArgs e)  
     DataView dv = new DataView(GetDataSet().Tables[0]);  
     dv.RowFilter = "accountno='" + Request.QueryString["accountno"].ToString() + "'";  
     GridView1.DataSource = dv;  


Please do not post any spam link in the comment box😊

Post a Comment (0)
Previous Post Next Post