ARTICLE

Know the Cell Position of table control in VB.NET

Posted by Satyapriya Nayak Articles | ASP.NET using VB.NET August 12, 2011
Here I will show you to create user defined table having rows and columns of your choice by selecting dropdownlist control and here we can able to know their respective cell positions.  
Reader Level:

Here I will show you to create user defined table having rows and columns of your choice by selecting dropdownlist control and here we can able to know their respective cell positions.

Program

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

    Sub h1(ByVal s As Object, ByVal e As EventArgs)

        Dim x, y, p, q As Integer

        x = select1.value

        y = select2.value

        For p = 0 To x - 1

            Dim r1 As New htmltablerow

            For q = 0 To y - 1

                Dim c1 As New htmltablecell

                c1.innerhtml = "cell " & p & "," & q

                r1.cells.add(c1)

            Next

            table1.rows.add(r1)

        Next

    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>

    <style type="text/css">

        #Button1

        {

            width: 174px;

        }

    </style>

</head>

<body>

    <form id="form1" runat="server"> 

    <select id="Select2" name="Select2" runat="server">

                        <option value="1"  selected>1</option>

                        <option value="2">2</option>

                        <option value="3">3</option>

                        <option value="4">4</option>

                        <option value="5">5</option>

                        <option value="6">6</option>

                        <option value="7">7</option>

                  </select>

                  <div>SEELCT NO OF COLS</div>            

                  <select id="Select1" name="Select1" runat="server">          

                        <option value="1"  selected>1</option>

                        <option value="2">2</option>

                        <option value="3">3</option>

                        <option value="4">4</option>

                        <option value="5">5</option>

                        <option value="6">6</option>

                        <option value="7">7</option>

                  </select><input id="Button1"  type="button" value="Select 2 dropdownlist click"

        name="Button1" runat="server" onserverclick="h1"/>

                  <div>SELECT NO OF ROWS</div>              

                  <table id="table1" width="300" border="10" runat="server" bordercolor ="#cc9933">

                  </table>

            </form>

      </body>

</html>

Output

table.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Nevron Diagram
Become a Sponsor