<%@ Page Language="C#" %> <html> <head id="Head1" runat="server"> <script runat="server"> public int NumberOfRows { get { return int.Parse(this.Request.Form[this.ddlRows.UniqueID] ?? "1"); } set { this.ddlRows.Text = value.ToString(); } } public int NumberOfColums { get { return int.Parse(this.Request.Form[this.txtColmns.UniqueID] ?? "4"); } set { this.txtColmns.Text = value.ToString(); } } protected override void OnInit(EventArgs e) { base.OnInit(e); Table table = new Table(); for (int i = 0; i < this.NumberOfRows; i++) { TableRow tr = new TableRow(); for (int j = 0; j < this.NumberOfColums; j++) { TableCell td = new TableCell(); td.Controls.Add(new TextBox() { ID = "Cell" + i + j }); tr.Controls.Add(td); } table.Rows.Add(tr); } this.phCells.Controls.Add(table); } </script> </head> <body> <form id="form1" runat="server"> Rows: <asp:DropDownList runat="server" ID="ddlRows"> <asp:ListItem Selected="True">5</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>15</asp:ListItem> <asp:ListItem>20</asp:ListItem> <asp:ListItem>25</asp:ListItem> </asp:DropDownList> - Coloums: <asp:TextBox runat="server" ID="txtColmns" Text="4" /> <hr /> <asp:PlaceHolder runat="server" ID="phCells"></asp:PlaceHolder> <asp:Button runat="server" ID="btnCreate" Text="Create" /> </form> </body> </html>
Monday, September 27, 2010
How to dynamically add a row of controls based on Drop Down List Value : Asp.net - Part 2
Demo:
Subscribe to:
Post Comments (Atom)
Azure Storage Account Types
Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...
-
Why we need asynchronous tasks? Execute a time consuming operations in parallel to the CLR thread which execute the request If you have ...
-
Demo: I was thinking a way to show images before actually uploading them to server. I would say to preview images using javascript. Obv...
No comments:
Post a Comment