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.Add Scrollbar to dynamic Panel using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="IamAzhar"> IamAzhar</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">&lt;asp:GridView ID=&#34;gvCustomers&#34; runat=&#34;server&#34; AutoGenerateColumns=&#34;false&#34;&gt; &lt;Columns&gt; &lt;asp:BoundField DataField=&#34;Name&#34; HeaderText=&#34;Name&#34; /&gt; &lt;asp:BoundField DataField=&#34;Status&#34; HeaderText=&#34;Status&#34; /&gt; &lt;/Columns&gt; &lt;/asp:GridView&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) { Panel Pnlcomment = new Panel(); Pnlcomment.ID = &#34;Pnlcomment&#34;; Pnlcomment.Style.Add(&#34;overflow&#34;, &#34;scroll&#34;); Pnlcomment.Style.Add(&#34;overflow-x&#34;, &#34;hidden&#34;); Pnlcomment.Style.Add(&#34;border-radius&#34;, &#34;12px&#34;); Pnlcomment.Style.Add(&#34; border&#34;, &#34;3px solid #fff&#34;); Pnlcomment.Style.Add(&#34;max-height&#34;, &#34;200px&#34;); Pnlcomment.Style.Add(&#34;width&#34;, &#34;150px&#34;); Pnlcomment.Style.Add(&#34;background-color&#34;, &#34;white&#34;); DataTable dt = new DataTable(); dt = new DataTable(); dt.Columns.AddRange(new DataColumn[2] { new DataColumn(&#34;Name&#34;), new DataColumn(&#34;Status&#34;) }); dt.Rows.Add(&#34;John&#34;, &#34;Pending&#34;); dt.Rows.Add(&#34;Rick&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;Andrew&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;Peter&#34;, &#34;Pending&#34;); dt.Rows.Add(&#34;Mudassar&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;John&#34;, &#34;Pending&#34;); dt.Rows.Add(&#34;Rick&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;Andrew&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;Peter&#34;, &#34;Pending&#34;); dt.Rows.Add(&#34;Mudassar&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;John&#34;, &#34;Pending&#34;); dt.Rows.Add(&#34;Rick&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;Andrew&#34;, &#34;Complete&#34;); dt.Rows.Add(&#34;Peter&#34;, &#34;Pending&#34;); dt.Rows.Add(&#34;Mudassar&#34;, &#34;Complete&#34;); this.gvCustomers.DataSource = dt; this.gvCustomers.DataBind(); Pnlcomment.Controls.Add(gvCustomers); form1.Controls.Add(Pnlcomment); } }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not Me.IsPostBack Then Dim Pnlcomment As Panel = New Panel() Pnlcomment.ID = &#34;Pnlcomment&#34; Pnlcomment.Style.Add(&#34;overflow&#34;, &#34;scroll&#34;) Pnlcomment.Style.Add(&#34;overflow-x&#34;, &#34;hidden&#34;) Pnlcomment.Style.Add(&#34;border-radius&#34;, &#34;12px&#34;) Pnlcomment.Style.Add(&#34; border&#34;, &#34;3px solid #fff&#34;) Pnlcomment.Style.Add(&#34;max-height&#34;, &#34;200px&#34;) Pnlcomment.Style.Add(&#34;width&#34;, &#34;150px&#34;) Pnlcomment.Style.Add(&#34;background-color&#34;, &#34;white&#34;) Dim dt As DataTable = New DataTable() dt = New DataTable() dt.Columns.AddRange(New DataColumn(1) {New DataColumn(&#34;Name&#34;), New DataColumn(&#34;Status&#34;)}) dt.Rows.Add(&#34;John&#34;, &#34;Pending&#34;) dt.Rows.Add(&#34;Rick&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;Andrew&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;Peter&#34;, &#34;Pending&#34;) dt.Rows.Add(&#34;Mudassar&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;John&#34;, &#34;Pending&#34;) dt.Rows.Add(&#34;Rick&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;Andrew&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;Peter&#34;, &#34;Pending&#34;) dt.Rows.Add(&#34;Mudassar&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;John&#34;, &#34;Pending&#34;) dt.Rows.Add(&#34;Rick&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;Andrew&#34;, &#34;Complete&#34;) dt.Rows.Add(&#34;Peter&#34;, &#34;Pending&#34;) dt.Rows.Add(&#34;Mudassar&#34;, &#34;Complete&#34;) Me.gvCustomers.DataSource = dt Me.gvCustomers.DataBind() Pnlcomment.Controls.Add(gvCustomers) form1.Controls.Add(Pnlcomment) End If End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/xPfxAn4.gif" alt="" width="247" height="354" /></p>https://www.aspforums.net:443/Threads/196139/Add-Scrollbar-to-dynamic-Panel-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/196139/Add-Scrollbar-to-dynamic-Panel-using-C-and-VBNet-in-ASPNet/Wed, 24 Jul 2019 05:27:58 GMT