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

Tabelle runtime - << VERSIONE VB.NET >>


Creare tabelle a runtime


<%@ Page language="c#" %>
<HTML>
<script language="C#" runat="server">
protected void Page_Load ( object src, EventArgs e )
{
  lb1.Text = "";
  lb2.Text = "";
}

private void btnCrea_Click(object sender, System.EventArgs e)
{
  int rowCnt = 0;
  int cellCnt = 0;
  try
  {
    rowCnt = Int16.Parse(tbRighe.Text);
  }
  catch
  {
    lb1.Text = "Inserisci un intero";
  }
  try
  {
    cellCnt = Int16.Parse(tbColonne.Text);
  }
  catch
  {
    lb2.Text = "Inserisci un intero";
  }
  if (rowCnt>0 && cellCnt>0)
  {
    for (int i=1; i<= rowCnt; i++)
    {
      TableRow tRow = new TableRow();
      for (int j=1; j<= cellCnt; j++)
      {
        TableCell tCell = new TableCell();
        tCell.Text = "Row"+i.ToString()+", "+"Col"+j.ToString();
        tRow.Cells.Add(tCell);
      }
      myTable.Rows.Add(tRow);
    }
  }
}
</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 style="WIDTH: 67px">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 style="WIDTH: 67px">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 style="WIDTH: 67px"></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>



Scarica il Codice...


Stampa la pagina


 








Inizio pagina

risorse per webmaster