dynamic html table with dynamic controls and how to increment Rows ?

I created a html table with dynamic controls like(dropdownlist,Textbox,checkbox) and I filled the controls  with the datatable fields.The row will be like following,


Dropdownlist(ddl1)      |          Textbox(txtb1)        |         Checkbox(chkb1)


I need one more row to be display in the table like the same Row, I i selected the dropdownlist or checkbox.Now the table with multiple rows displaying(I used Divs instead of table here).But I don't know how to write code inside the "selectedindexchanged" event of dropdownlist. Will You please help me to solve this issue. The following is my code.

3/3/2008 11:15:16 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 11

Please find the code below....

Imports System.Data
Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Drawing
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls

Partial Class checkdy
    Inherits System.Web.UI.Page
    Dim ds1 As New Data.DataSet
    Dim str As String
    Dim count1 As Integer
    Dim div1, div11, div12, div13 As HtmlGenericControl
    'Protected ddl1 As System.Web.UI.WebControls.DropDownList
    ' Added by hand; will create instance in OnInit.
    Protected WithEvents ddl1 As System.Web.UI.WebControls.DropDownList
    ' Added by hand; will create instance in OnInit.
    Protected WithEvents chkb1 As System.Web.UI.WebControls.CheckBox

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Qstr = "select ddltext from cedrec_grid1"
        QCommand(Qstr, ds1)
        ' Dim k As Integer = ds1.Tables(0).Rows.Count
        For i As Integer = 0 To ds1.Tables(0).Rows.Count - 1
            Dim div1 As HtmlGenericControl = New HtmlGenericControl()
            div1.Style.Add("float", "left")
            div1.Style.Add("border", "1px solid red")
            div1.Style.Add("width", "250px")
            div1.Style.Add("height", "25px")

            Dim div11 As HtmlGenericControl = New HtmlGenericControl()
            div11.Style.Add("float", "left")
            div11.Style.Add("width", "80px")
            div11.Style.Add("height", "20px")
            div11.Style.Add("border-right", "1px solid red")
            Dim ddl1 As DropDownList = New DropDownList()
            ddl1.ID = "ddl1" & i.ToString
            For j As Integer = 0 To ds1.Tables(0).Rows.Count - 1
                ddl1.Items.Add(New ListItem(ds1.Tables(0).Rows(j).Item("ddltext")))
            AddHandler ddl1.SelectedIndexChanged, AddressOf Me.ddl1_SelectedIndexChanged
            ddl1.AutoPostBack = True
            count1 = i
            'str = ds1.Tables(0).Rows(i).Item("ddltext")
            Dim div12 As HtmlGenericControl = New HtmlGenericControl()
            div12.Style.Add("float", "left")
            div12.Style.Add("width", "80px")
            div12.Style.Add("height", "20px")
            div12.Style.Add("display", "inline")
            div12.Style.Add("border-right", "1px solid red")

            Dim txtb1 As TextBox = New TextBox
            txtb1.Style.Add("width", "60px")
            txtb1.Style.Add("margin-left", "10px")

            Dim div13 As HtmlGenericControl = New HtmlGenericControl()
            div13.Style.Add("float", "right")
            div13.Style.Add("width", "80px")
            div13.Style.Add("height", "20px")
            div13.Style.Add("display", "inline")
            Dim chkb1 As CheckBox = New CheckBox
            chkb1.ID = "chkb1" & i.ToString
            AddHandler chkb1.CheckedChanged, AddressOf Me.chkb1_CheckedChanged
            chkb1.AutoPostBack = True

            chkb1.Style.Add("float", "left")
            chkb1.Text = ds1.Tables(0).Rows(i).Item("ddltext")
            If i >= 1 Then
                div1.Visible = False
            End If
        Next i
    End Sub

Protected Sub ddl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl1.SelectedIndexChanged

    End Sub

3/3/2008 12:06:54 PM

Similar Artilces:

dynamically creating html controls on web form
hello all, I'm creating html <input type="file" name="test" id="test" runat="server"> dynamically using Javascript on a .aspx page. when i submit the form i get Javascript "Access is denied" error. if i take out name attribute from input tag in javascript -  it is not throwing any javascript error but the file is not being uploaded to the server. Can anyone point me in the right direction? Thanx in advance     Maybe this is a security restriction imposed by the browser? I know there are several constrain...

create and add controls dynamically to dynamically created Table Control
How can i create web server Table control dynamically with vary number of  rows and columns, and  then adding  further  other controls(like  dropdown, Text box etc.)  randomly to the specific created Table Cells. First of all you should use PlaceHolder control to add Table control to it:<asp:PlaceHolder id="PH" runat="server"></asp:PlaceHolder>Code Behinde:Table t = new Table();TableRow tr = new TableRow();TableCell td = new TableCell();//td.Text = "Hello, I am a TD";// Here well create TextBox and add it to TDTextBox txt = new TextBox();tx...

Dynamic table generation by JavaScript, Accessing row and data of dynamic table in C# code
  <div>   <input id="txtName" type="text"/> <input id="txtAdd" type="text"/> <input id="txtCity" type="text"/>   <input id="btnAdd" type="button" value="Add" onclick="AddClick();" /> <input id="btnRemove" type="button" value="Remove" onclick="RemoveClick(this);"/><br /> <table id="tblInfo" runat="server" style="width: 474px" > </table> </div&g...

creating dynamic HTML input controls on Label web control
hello, i would like to know whether it is possible to create dynamic HTML controls like radio buttons onto a Label web control? if it is, can someone show me how to go about doing it?  premit wrote: like radio buttons onto a Label web controlHi,could you please clarify this somewhat more? Know that the Label server control maps to a <span> tag in html so you could change the innerhtml with dhtml if you like.Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. you could do:lblMyLabel.Text = "<input type=\"radio\...

Create dynamic form and form controls inside a table at runtime
I'm migrating a Classic ASP application.  The application migration is supposed to keep the same look and feel of the existing application.  I.E. as we roll out parts of the application the user has no idea that we've made any changes.  The basic direction is "Change it, but we don't want to see it change in any way." The User Control is a datagrid on steroids and then some.  It extends the basic datagrid concept with much more functionality.  We went this route because the basic premise is to maintain the existing look and feel.  For exam...

Create html table dynamically in a html table
I need create a html table with 2 rows and in first row contains 1 html table.How do I create this tables dynamically.example:<TABLE>  <TR>    <TABLE>      <TD>Primeira Coluna - Primeira Linha</TD>      <TD>Segunda Coluna - Primeira Linha</TD>    </TABLE>  </TR>  <TR>    <TD>Primeira Coluna - Segunda Linha</TD>    <TD>Segunda Coluna - Segunda Linha</TD>    <TD>Login</...

Dynamic Controls Within Dynamic Controls
Ok, So here's what i'm trying to do: I have the first set of controls, on the page which are dynamicly added, i'll just show simplified code, do to the complex nature of the full thing, so this is part one: private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) Label1.Text = ""; for (int i = 0; i < 10; i++) { Button li = new Button(); li.Text = "Click Me - " + i.ToString(); li.ID = i.ToString();   li.Click +=new EventHandler(li_Click); PlaceHolder1.Controls.Add(li); PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));   } } N...

User Control Issue
Dupelicate post dancioffi: Dupelicate post Please refer to this: http://forums.asp.net/t/1398304.aspxGary yang - MSFTMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Web Form Dynamic Control
Hello, I have a web form using .net 2.0.  When the user finishes entering in information it is mailed.  This works fine. Now I need to be able to dynmaicly add addtional controls. Basicly have a "Add Additonal Names" button, when user clicks this a row and cells are added to the webform table, and two textoboxes and a radiobutton list is added. What is the best way to do this?   -TFTH Bryan The easiest way is to place the controls on the page and set their visible value to false. Then in the button click event change their state to visible. The visible var in a contro...

Dynamic TextBox control inside a dynamic created table???
I have a table beeing created dynamicaly in a page and I need to create a textbox inside it, I tried to create a placeholder inside the table cell but after testing I rebered that placeholder and codes suck <asp:... are compiled before the page loads so I cant change they by script in execution time Any Ideia??? I'm using C# thanks to anyone who try to help me hi,  Well i know how to put tables and textboxes into placeholders hope it gives u an idea. Firstly create a placeholder in the web form then protected void Page_Load(object sender, System.EventArgs e) { ...

Dynamic pictures on UA forms (and other dynamic html on those as well)
Hello, I'm trying to link to some pictures, dynamically in a html control on my UA request form. It is kinda cumbersome I think I've done 2 things I put this into the html content on the html control <div id='imgContainer' align='center'></div> That gives me a container for my image (or at least it does in firefox, it doesn't work in IE, which I must look into at some point). In another control I generate an event when browsing through objects. In the html control I react on the event with this. function myFunc () { var x...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

postback from dynamic controls to create more dynamic controls
Hi, Could any one help me?  I have a masterpage with dynamically created list boxes.  When the user selects an item from the listbox the selected value will be used to dynamically create a set of controls in the contentplaceholder.  The problem i have is that the item selected from the list box is posted back and i do not know what the selected item is until the life cycle is complete.  During the post back is there a way to findout which listbox control performed a post back and its value before i get to the init part of the content page where i woul...

Dynamically Outputting HTML Content and Dynamic Server Side Controls
Hi,  I am trying to write a complex survey application but need some help.  I want to write out custom HTML (DIV tags) etc on the fly as i build the form elements aswell.  I am unsure how to do this and would greatly appreciate some links to things i could consider.  Rob Here is a good series on creating dynamic controls: http://devsushi.com/2006/08/27/aspnet-dynamic-control-creation-part-1/   Take a look in the HtmlGenericControl. You can create custom HTML and add them to the page using Page.Controls.Add method. The Controls attribute exists in the Con...

Web resources about - dynamic html table with dynamic controls and how to increment Rows ? - asp.net.web-forms

Tax increment financing - Wikipedia, the free encyclopedia
Tax increment financing , or TIF , is a public financing method that is used as a subsidy for redevelopment , infrastructure, and other community-improvement ...

Sponsors say new Alabama tax increment finance law about luring high-tech jobs, not eminent domain
In his Monday column, Birmingham News and al.com columnist John Archibald said Senate Bill 96 allows the government to seize private property ...

Dementia in 140 Character Increments
777crash confirms jihadists turning to make trouble for China. Chance for US to make common cause, befriend China while Russia bullies. — Rupert ...

Small Increments to Make Big Traffic
Many bloggers ask me in desperation what they are doing wrong. They work hard and don’t seem to be making any progress. They hear talk of a snowball ...

Roger Ebert Is 'Dying In Increments,' But Blogging The Best Work Of His Life
One of the world's most famous movie critics describes his online journal: "It is saving me."

Circle Battery Widget Introduces 1% Battery Increments for the DROID X and Other Motorola Phones
... is monumental. The developer behind Circle Battery Widget somehow figured out a way to get batteries on Moto devices to show up in 1% increments ...

Evolving UX with Small Increments
I’ve started noticing more details of UX design in the software I use on a daily basis. Recently I noted an example of reducing a two-click flow ...

Vine's loop counts tally plays in five-second increments
Until now, Vine's stats only indicated likes and revines for those carefully crafted five-second masterpieces. With an update rolling out today, ...

Tax Increment Financing Is The New Urban Renewal
Despite the failures of post-World War II "urban renewal" and "slum clearance," cities repeat the mistake with tax increment financing.

Iteration, Increments, and Timeboxes
Effective software development Like many words, we often use “iterative” and “incremental” quite loosely. I’m OK with that, until that lack of ...

Resources last updated: 1/16/2016 6:39:38 PM