ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display ASP.Net GridView row details in AJAX Modal Popup Extender on LinkButton Click using C# and VB.Net<p>Hi <a class="username" rel="yogeshc"> yogeshc</a>,</p> <p>You need to find label control. refer below code will help you out.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;style&gt; .example-modal .modal { position: relative; top: auto; bottom: auto; right: auto; left: auto; display: block; z-index: 1; } .example-modal .modal { background: transparent !important; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;section class=&#34;content&#34;&gt; &lt;div class=&#34;row&#34;&gt; &lt;div class=&#34;col-md-12&#34;&gt; &lt;!-- general form elements disabled --&gt; &lt;div class=&#34;box box-primary&#34;&gt; &lt;div class=&#34;box-header with-border&#34;&gt; &lt;h3 class=&#34;box-title&#34;&gt;List E-Pin Request&lt;/h3&gt; &lt;/div&gt;&lt;!-- /.box-header --&gt; &lt;div class=&#34;box-body&#34;&gt; &lt;!-- text input --&gt; &lt;div class=&#34;form-group&#34; align=&#34;center&#34; style=&#34;height:650PX; overflow:scroll&#34;&gt; &lt;asp:ScriptManager ID=&#34;ScriptManager1&#34; runat=&#34;server&#34;&gt; &lt;/asp:ScriptManager&gt; &lt;asp:UpdatePanel ID=&#34;UpdatePanel1&#34; runat=&#34;server&#34;&gt; &lt;ContentTemplate&gt; &lt;asp:GridView ID=&#34;GridView1&#34; runat=&#34;server&#34; EmptyDataText=&#34;No Record Found&#34; DataKeyNames=&#34;Id&#34; AutoGenerateColumns=&#34;False&#34; GridLines=&#34;None&#34; &gt; &lt;Columns&gt; &lt;asp:TemplateField HeaderText = &#34;S.No&#34; ItemStyle-Width=&#34;50&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;lblRowNumber&#34; Text=&#39;&lt;%# Container.DataItemIndex + 1 %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width=&#34;50px&#34;&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText = &#34;Request Id&#34; ItemStyle-Width=&#34;70&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;lblreqId&#34; Text=&#39;&lt;%# Eval(&#34;id&#34;) %&gt;&#39; runat=&#34;server&#34; /&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width=&#34;70px&#34;&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText=&#34;User Id&#34; ItemStyle-Width=&#34;100&#34; &gt; &lt;ItemTemplate&gt; &lt;asp:Label ID=&#34;lbluserid&#34; runat=&#34;server&#34; readOnly=&#34;true&#34; Text=&#39;&lt;%# Eval(&#34;User_id&#34;) %&gt;&#39;&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width=&#34;100px&#34;&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText=&#34;Deposite Amount&#34; ItemStyle-Width=&#34;130&#34;&gt; &lt;ItemTemplate &gt; &lt;asp:Label ID=&#34;lblamt&#34; runat=&#34;server&#34; readOnly=&#34;true&#34; Text=&#39;&lt;%# Eval(&#34;Deposite_amount&#34;) %&gt;&#39;&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width=&#34;130px&#34;&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField HeaderText=&#34;Request Date&#34; ItemStyle-Width=&#34;100&#34;&gt; &lt;ItemTemplate &gt; &lt;asp:Label ID=&#34;lblrdate&#34; runat=&#34;server&#34; readOnly=&#34;true&#34; Text=&#39;&lt;%# Eval(&#34;Request_Date&#34;) %&gt;&#39;&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width=&#34;100px&#34;&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:BoundField DataField=&#34;Request_Status&#34; HeaderText=&#34;Request Status&#34; ItemStyle-Width=&#34;100&#34; SortExpression=&#34;Request_Status&#34; readOnly=&#34;true&#34; /&gt; &lt;asp:TemplateField HeaderText=&#34;Remark&#34; ItemStyle-Width=&#34;200&#34;&gt; &lt;ItemTemplate &gt; &lt;asp:Label ID=&#34;lblremark&#34; runat=&#34;server&#34; readOnly=&#34;true&#34; Text=&#39;&lt;%# Eval(&#34;Remark&#34;) %&gt;&#39;&gt;&lt;/asp:Label&gt; &lt;/ItemTemplate&gt; &lt;ItemStyle Width=&#34;200px&#34;&gt;&lt;/ItemStyle&gt; &lt;/asp:TemplateField&gt; &lt;asp:TemplateField ItemStyle-Width = &#34;30px&#34; HeaderText =&#34;E-Pin&#34;&gt; &lt;ItemTemplate&gt; &lt;asp:LinkButton ID=&#34;lnkEdit&#34; runat=&#34;server&#34; Text = &#34;Generate&#34; OnClick = &#34;Edit&#34;&gt;&lt;/asp:LinkButton&gt; &lt;/ItemTemplate&gt; &lt;/asp:TemplateField&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;asp:Panel ID=&#34;pnlAddEdit&#34; runat=&#34;server&#34; CssClass=&#34;modalPopup&#34; style = &#34;display:none&#34;&gt; &lt;div class=&#34;example-modal&#34;&gt; &lt;div class=&#34;modal modal-primary&#34;&gt; &lt;div class=&#34;modal-dialog&#34;&gt; &lt;div class=&#34;modal-content&#34;&gt; &lt;div class=&#34;modal-header&#34;&gt; &lt;h4 class=&#34;modal-title&#34;&gt;Generate E-Pin&lt;/h4&gt; &lt;/div&gt; &lt;div class=&#34;modal-body&#34;&gt; &lt;div class=&#34;row&#34;&gt; &lt;!-- text input --&gt; &lt;div class=&#34;col-md-6&#34;&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;asp:TextBox ID=&#34;txtuserid&#34; runat=&#34;server&#34; CssClass=&#34;form-control&#34; ReadOnly=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;asp:TextBox ID=&#34;txtamt&#34; runat=&#34;server&#34; CssClass=&#34;form-control&#34; ReadOnly=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;asp:DropDownList ID=&#34;DDLpack&#34; runat=&#34;server&#34; CssClass=&#34;form-control&#34; &gt; &lt;/asp:DropDownList&gt; &lt;asp:RequiredFieldValidator ID=&#34;RequiredFieldValidator2&#34; runat=&#34;server&#34; ForeColor=&#34;Red&#34; ErrorMessage=&#34;select Package&#34; ControlToValidate=&#34;DDLpack&#34; InitialValue=&#34;Select Package&#34; ValidationGroup=&#34;validateformregis&#34;&gt;&lt;/asp:RequiredFieldValidator&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&#34;col-md-6&#34;&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;asp:TextBox ID=&#34;txtreqid&#34; runat=&#34;server&#34; CssClass=&#34;form-control&#34; ReadOnly=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;div class=&#34;input-group&#34;&gt; &lt;div class=&#34;input-group-addon&#34;&gt; &lt;i class=&#34;fa fa-calendar&#34;&gt;&lt;/i&gt; &lt;/div&gt; &lt;asp:TextBox ID=&#34;txtdt&#34; runat=&#34;server&#34; CssClass=&#34;form-control&#34; placeholder=&#34;Request Date mm/dd/yyyy&#34; ReadOnly=&#34;true&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&#34;form-group&#34;&gt; &lt;asp:TextBox ID=&#34;txtpinno&#34; runat=&#34;server&#34; CssClass=&#34;form-control&#34; placeholder=&#34;Enter No of Pins&#34;&gt;&lt;/asp:TextBox&gt; &lt;/div&gt; &lt;asp:Button ID=&#34;Button1&#34; runat=&#34;server&#34; cssclass=&#34;btn btn-primary pull-right &#34; Text=&#34;Generate&#34; /&gt; &lt;/div&gt; &lt;asp:Panel ID=&#34;Panel2&#34; runat=&#34;server&#34; Visible=&#34;false&#34; &gt; &lt;div class=&#34;col-md-12&#34;&gt; &lt;asp:GridView ID=&#34;GridView2&#34; runat=&#34;server&#34; CssClass=&#34;table table-hover&#34; AutoGenerateColumns=&#34;false&#34;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&#34;Id&#34; HeaderText=&#34;Id&#34; ItemStyle-Width=&#34;30&#34; /&gt; &lt;asp:BoundField DataField=&#34;user_id&#34; HeaderText=&#34;User Id&#34; ItemStyle-Width=&#34;100&#34; /&gt; &lt;asp:BoundField DataField=&#34;Request_date&#34; HeaderText=&#34;Request Date&#34; ItemStyle-Width=&#34;100&#34; /&gt; &lt;asp:BoundField DataField=&#34;EPin&#34; HeaderText=&#34;E-Pin&#34; ItemStyle-Width=&#34;100&#34; /&gt; &lt;asp:BoundField DataField=&#34;Pin_Price&#34; HeaderText=&#34;Pin Price&#34; ItemStyle-Width=&#34;100&#34; /&gt; &lt;asp:BoundField DataField=&#34;Generate_date&#34; HeaderText=&#34;Generate Date&#34; ItemStyle-Width=&#34;100&#34; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/div&gt; &lt;/asp:Panel&gt; &lt;/div&gt; &lt;div class=&#34;modal-footer&#34;&gt; &lt;asp:Button ID=&#34;btnCancel&#34; runat=&#34;server&#34; cssclass=&#34;btn btn-default pull-left&#34; Text=&#34;Cancel&#34; /&gt; &lt;asp:Button ID=&#34;btnSave&#34; runat=&#34;server&#34; cssclass=&#34;btn btn-primary&#34; Text=&#34;save&#34; /&gt; &lt;/div&gt; &lt;/div&gt;&lt;!-- /.modal-content --&gt; &lt;/div&gt;&lt;!-- /.modal-dialog --&gt; &lt;/div&gt;&lt;!-- /.modal --&gt; &lt;/div&gt; &lt;/asp:Panel&gt; &lt;asp:LinkButton ID=&#34;lnkFake&#34; runat=&#34;server&#34;&gt;&lt;/asp:LinkButton&gt; &lt;asp:ModalPopupExtender ID=&#34;popup&#34; runat=&#34;server&#34; DropShadow=&#34;false&#34; PopupControlID=&#34;pnlAddEdit&#34; TargetControlID = &#34;lnkFake&#34; BackgroundCssClass=&#34;modalBackground&#34;&gt; &lt;/asp:ModalPopupExtender&gt; &lt;/ContentTemplate&gt; &lt;Triggers&gt; &lt;asp:AsyncPostBackTrigger ControlID = &#34;GridView1&#34; /&gt; &lt;asp:AsyncPostBackTrigger ControlID = &#34;btnSave&#34; /&gt; &lt;asp:AsyncPostBackTrigger ControlID = &#34;GridView2&#34; /&gt; &lt;asp:AsyncPostBackTrigger ControlID = &#34;Button1&#34; /&gt; &lt;/Triggers&gt; &lt;/asp:UpdatePanel&gt; &lt;/div&gt; &lt;/div&gt;&lt;!-- /.box-body --&gt; &lt;/div&gt;&lt;!-- /.box --&gt; &lt;!-- Horizontal Form --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/section&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Data; </pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Data</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add(&#34;id&#34;); dt.Columns.Add(&#34;User_id&#34;); dt.Columns.Add(&#34;Deposite_amount&#34;); dt.Columns.Add(&#34;Request_Date&#34;); dt.Columns.Add(&#34;Request_Status&#34;); dt.Columns.Add(&#34;Remark&#34;); dt.Rows.Add(1, &#34;u1&#34;, &#34;545&#34;, &#34;01/02/2019&#34;, &#34;0&#34;, &#34;no&#34;); dt.Rows.Add(2, &#34;u2&#34;, &#34;545&#34;, &#34;01/05/2019&#34;, &#34;0&#34;, &#34;yes&#34;); GridView1.DataSource = dt; GridView1.DataBind(); } } protected void Edit(object sender, EventArgs e) { GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent; txtreqid.Text = (row.FindControl(&#34;lblreqId&#34;) as Label).Text; txtuserid.Text = (row.FindControl(&#34;lbluserid&#34;) as Label).Text; txtamt.Text = (row.FindControl(&#34;lblamt&#34;) as Label).Text; txtdt.Text = (row.FindControl(&#34;lblrdate&#34;) as Label).Text; popup.Show(); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handle Me.Load If Not Me.IsPostBack Then Dim dt As DataTable = New DataTable() dt.Columns.Add(&#34;id&#34;) dt.Columns.Add(&#34;User_id&#34;) dt.Columns.Add(&#34;Deposite_amount&#34;) dt.Columns.Add(&#34;Request_Date&#34;) dt.Columns.Add(&#34;Request_Status&#34;) dt.Columns.Add(&#34;Remark&#34;) dt.Rows.Add(1, &#34;u1&#34;, &#34;545&#34;, &#34;01/02/2019&#34;, &#34;0&#34;, &#34;no&#34;) dt.Rows.Add(2, &#34;u2&#34;, &#34;545&#34;, &#34;01/05/2019&#34;, &#34;0&#34;, &#34;yes&#34;) GridView1.DataSource = dt GridView1.DataBind() End If End Sub Protected Sub Edit(ByVal sender As Object, ByVal e As EventArgs) Dim row As GridViewRow = CType((CType(sender, LinkButton)).Parent.Parent, GridViewRow) txtreqid.Text = (TryCast(row.FindControl(&#34;lblreqId&#34;), Label)).Text txtuserid.Text = (TryCast(row.FindControl(&#34;lbluserid&#34;), Label)).Text txtamt.Text = (TryCast(row.FindControl(&#34;lblamt&#34;), Label)).Text txtdt.Text = (TryCast(row.FindControl(&#34;lblrdate&#34;), Label)).Text popup.Show() End Sub</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/112822/Display-ASPNet-GridView-row-details-in-AJAX-Modal-Popup-Extender-on-LinkButton-Click-using-C-and-VBNet/https://www.aspforums.net:443/Threads/112822/Display-ASPNet-GridView-row-details-in-AJAX-Modal-Popup-Extender-on-LinkButton-Click-using-C-and-VBNet/Mon, 09 Sep 2019 05:32:51 GMT