Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Runtime Tables - << C# VERSION >>


How tu create thml tables at runtime


<%@ Page language="VB" Debug="false" %>
<HTML>
<script language="vbscript" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  lb1.Text = ""
  lb2.Text = ""
End Sub

Private Sub btnCrea_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  Dim rowCnt As Integer = 0
  Dim cellCnt As Integer = 0
  Try
    rowCnt = Int16.Parse(tbRighe.Text)
  Catch
    lb1.Text = "Inserisci un intero"
  End Try
  Try
    cellCnt = Int16.Parse(tbColonne.Text)
  Catch
    lb2.Text = "Inserisci un intero"
  End Try
  If rowCnt > 0 And cellCnt > 0 Then
    For i As Integer = 1 To rowCnt
      Dim tRow As TableRow = New TableRow
      For j As Integer = 1 To cellCnt
        Dim tCell As TableCell = New TableCell
        tCell.Text = "Row" & i.ToString() & ", " & "Col" + j.ToString()
        tRow.Cells.Add(tCell)
        myTable.Rows.Add(tRow)
      Next
    Next
  End If
End Sub
</script>
<body>
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" style="WIDTH: 511px; HEIGHT: 101px" cellSpacing="1" cellPadding="1"
width="511" border="0">
<TR>
<TD width="67">Righe</TD>
<TD>
<asp:TextBox id="tbRighe" runat="server" Width="44px"></asp:TextBox>
<asp:Label id="lb1" runat="server"></asp:Label></TD>
</TR>
<TR>
<TD width="67">Colonne</TD>
<TD>
<asp:TextBox id="tbColonne" runat="server" DESIGNTIMEDRAGDROP="16" Width="42px"></asp:TextBox>
<asp:Label id="lb2" runat="server"></asp:Label></TD>
</TR>
<TR>
<TD width="67"></TD>
<TD>
<asp:Button id="btnCrea" runat="server" Text="Crea!" OnClick="btnCrea_Click"></asp:Button></TD>
</TR>
</TABLE>
<BR>
<HR width="100%" SIZE="1">
<BR>
<asp:Table id="myTable" runat="server" BorderWidth="1px" BorderStyle="Solid" BorderColor="Gray"
BackColor="#E0E0E0" CellPadding="4" CellSpacing="0" GridLines="Both"></asp:Table></form>
</body>
</HTML>



Download Code...


Print Page


 








Page top

risorse per webmaster