Hi,
I wants to Create Control dynamically / runtime on button click in Sharepoint 2010 Application page one Drop down and a TextBox on 'More' button click in row of a table and wants those value on another 'Submit' Button click.
On page load view is like
on 'More' button click
Now when I click 'More' button for third row then it doesn't comes.
I checked html source so get to know new controls are rendering and previous controls those are created by button are disappearing by looking at ID like text0 is there afer on click txtBox1 comes after next click txtBox2 comes but text1 disappears as well and in uls logs got below error
This error may also indicate a programming error caused by obtaining two copies of the same object in a single thread.
my .CS C# code
private void CreateRow(string count) { DVDropDownList oDynamicddCondition = new DVDropDownList(); oDynamicddCondition.ID = "ddCondition" + count.ToString(); InputFormTextBox oDynamicTextBox = new InputFormTextBox(); oDynamicTextBox.ID = "txtValue" + count; oDynamicddCondition.Items.Add("test"); System.Web.UI.WebControls.TableRow row = new System.Web.UI.WebControls.TableRow(); System.Web.UI.WebControls.TableCell otdDCondition = new System.Web.UI.WebControls.TableCell(); System.Web.UI.WebControls.TableCell otdTextBox = new System.Web.UI.WebControls.TableCell(); row.ID = "trRow" + count; otdTextBox.ID = "tdText" + count; otdDCondition.ID = "tdConditions" + count; otdDCondition.Controls.Add(oDynamicddCondition); otdTextBox.Controls.Add(oDynamicTextBox); row.Cells.Add(otdDCondition); row.Cells.Add(otdTextBox); tableCondition.Rows.Add(row);
below is my aspx code
<asp:Table Style="MARGIN-TOP: 8px" CellSpacing='3' CellPadding='3' ID="tableCondition" runat="server"><asp:TableRow ID="trRow0"><asp:TableCell ID="tdAllfilds0"><asp:TableCell ID="tdConditions0"><SharePoint:DVDropDownList ID="ddCondition0" runat="server"><asp:ListItem Text="Equal" Value="=="></asp:ListItem><asp:ListItem Text="Not Equal" Value="!="></asp:ListItem></SharePoint:DVDropDownList></asp:TableCell><asp:TableCell ID="tdText0"><SharePoint:InputFormTextBox ID="txtValue0" runat="server"></SharePoint:InputFormTextBox></asp:TableCell></asp:TableRow> </asp:Table>
Now please let me know where and what is am I missing? the number of row may be 1, 2, 4, 10 anything.
I appreciate for any help.
Thanks