i have one aspx page in which i have taken textbox , dropdownlist and placeholder. In dropdownlist i have listitem like- textbox,multitextbox,checkbox etc. when i select anyone it show in place holder. now i want to save particular contro data in database
at run time and also want to show this control in repeater
i have one aspx page in which i have taken textbox , dropdownlist and placeholder. In dropdownlist i have listitem like- textbox,multitextbox,checkbox etc. when i select anyone it show in place holder.
For your description, you want to add the control in the place holder when you select the dropdownlist. Please check the demo below:
These controls are dynamically created and added to the placeholder. Thus, you need to save them in the
viewstate. Otherwise, they will get lost when you do a postback.
surfarajist
now i want to save particular contro data in database at run time and also want to show this control in repeater
For more information about how to add the control in the repeater, please check the link below:
surfarajist
0 Points
10 Posts
placeholder problem
Jun 30, 2012 03:49 PM|LINK
i have one aspx page in which i have taken textbox , dropdownlist and placeholder. In dropdownlist i have listitem like- textbox,multitextbox,checkbox etc. when i select anyone it show in place holder. now i want to save particular contro data in database at run time and also want to show this control in repeater
Catherine Sh...
All-Star
23373 Points
2490 Posts
Microsoft
Re: placeholder problem
Jul 02, 2012 09:21 AM|LINK
Hi,
For your description, you want to add the control in the place holder when you select the dropdownlist. Please check the demo below:
In the .aspx
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" onselectedindexchanged="DropDownList1_SelectedIndexChanged"> <asp:ListItem>textbox</asp:ListItem> <asp:ListItem>multitextbox</asp:ListItem> <asp:ListItem>checkbox </asp:ListItem> </asp:DropDownList> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>In the code behind:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { if(DropDownList1.SelectedValue=="textbox") { TextBox textboxtest = new TextBox(); textboxtest.Text = "textboxtest"; textboxtest.ID = "textboxid"; PlaceHolder1.Controls.Add(textboxtest); } else if( DropDownList1.SelectedValue== "multitextbox") { TextBox multitextbox = new TextBox(); multitextbox.Text = "multitextbox"; multitextbox.ID = "multitextboxid"; multitextbox.TextMode = TextBoxMode.MultiLine; PlaceHolder1.Controls.Add(multitextbox); } else if (DropDownList1.SelectedValue == "checkbox") { CheckBox CheckBoxtest = new CheckBox(); CheckBoxtest.Text = "test"; CheckBoxtest.ID = "textboxid"; CheckBoxtest.Checked = true; PlaceHolder1.Controls.Add(CheckBoxtest); } }These controls are dynamically created and added to the placeholder. Thus, you need to save them in the viewstate. Otherwise, they will get lost when you do a postback.
For more information about how to add the control in the repeater, please check the link below:
http://www.ezineasp.net/post/ASP-Net-Repeater-dynamically-using-C-sharp-code.aspx
Best wishes,
Feedback to us
Develop and promote your apps in Windows Store