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.Create dynamic Table based on Row and Column value from TextBox using C# and VB.Net in ASP.Net<p>Hi <a class="username" rel="nid@patel"> nid@patel</a>,</p> <p>Refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <pre class="brush: html">Height:&lt;div&gt; &lt;asp:TextBox ID=&#34;TextBox1&#34; runat=&#34;server&#34; Text=&#34;200px&#34;&gt;&lt;/asp:TextBox&gt;&lt;/div&gt; Width:&lt;div&gt; &lt;asp:TextBox ID=&#34;TextBox2&#34; runat=&#34;server&#34; Text=&#34;150px&#34;&gt;&lt;/asp:TextBox&gt;&lt;/div&gt; Row:&lt;div&gt; &lt;asp:TextBox ID=&#34;TextBox3&#34; runat=&#34;server&#34; Text=&#34;5&#34;&gt;&lt;/asp:TextBox&gt;&lt;/div&gt; Column:&lt;div&gt; &lt;asp:TextBox ID=&#34;TextBox4&#34; runat=&#34;server&#34; Text=&#34;5&#34;&gt;&lt;/asp:TextBox&gt;&lt;/div&gt; &lt;br /&gt; &lt;div id=&#34;TableHtml&#34; runat=&#34;server&#34;&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;"><strong>Namespaces</strong></span></p> <p><strong>C#</strong></p> <pre class="brush: csharp">using System.Text;</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Imports System.Text</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) { StringBuilder sb = new StringBuilder(); sb.Append(&#34;&lt;table border=&#39;1&#39; height = &#39;&#34; + TextBox1.Text + &#34;&#39; width=&#39;&#34; + TextBox2.Text + &#34;&#39;&gt;&#34;); sb.Append(&#34;&lt;tr&gt;&#34;); for (int i = 0; i &lt; Convert.ToInt16(TextBox4.Text); i++) { sb.Append(&#34;&lt;th&gt;&#34; + i + &#34;&lt;/th&gt;&#34;); } sb.Append(&#34;&lt;/tr&gt;&#34;); for (int j = 1; j &lt;= Convert.ToInt16(TextBox3.Text); j++) { sb.Append(&#34;&lt;tr&gt;&#34;); for (int k = 0; k &lt; Convert.ToInt16(TextBox4.Text); k++) { sb.Append(&#34;&lt;td&gt;&#34; + j + &#34;&lt;/td&gt;&#34;); } sb.Append(&#34;&lt;/tr&gt;&#34;); } sb.Append(&#34;&lt;/tr&gt;&lt;/table&gt;&#34;); TableHtml.InnerHtml = sb.ToString(); } }</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 sb As StringBuilder = New StringBuilder() sb.Append(&#34;&lt;table border=&#39;1&#39; height = &#39;&#34; &amp; TextBox1.Text &amp; &#34;&#39; width=&#39;&#34; + TextBox2.Text &amp; &#34;&#39;&gt;&#34;) sb.Append(&#34;&lt;tr&gt;&#34;) For i As Integer = 0 To Convert.ToInt16(TextBox4.Text) - 1 sb.Append(&#34;&lt;th&gt;&#34; &amp; i &amp; &#34;&lt;/th&gt;&#34;) Next sb.Append(&#34;&lt;/tr&gt;&#34;) For j As Integer = 1 To Convert.ToInt16(TextBox3.Text) sb.Append(&#34;&lt;tr&gt;&#34;) For k As Integer = 0 To Convert.ToInt16(TextBox4.Text) - 1 sb.Append(&#34;&lt;td&gt;&#34; &amp; j &amp; &#34;&lt;/td&gt;&#34;) Next sb.Append(&#34;&lt;/tr&gt;&#34;) Next sb.Append(&#34;&lt;/tr&gt;&lt;/table&gt;&#34;) TableHtml.InnerHtml = sb.ToString() End If End Sub</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/9POoAO3.jpg" alt="" width="193" height="337" /></p>https://www.aspforums.net:443/Threads/484349/Create-dynamic-Table-based-on-Row-and-Column-value-from-TextBox-using-C-and-VBNet-in-ASPNet/https://www.aspforums.net:443/Threads/484349/Create-dynamic-Table-based-on-Row-and-Column-value-from-TextBox-using-C-and-VBNet-in-ASPNet/Mon, 05 Aug 2019 04:27:00 GMT