Re: problem to insert value in dropdownlist on formView control
"Graf, Jim" <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.advanced |
|---|---|
| Message-ID | <34756C0621C87044A42AA03C73A0B67501A8F86B@schexchmb02.ems.us.experian.local> |
yes -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of lior levi Sent: Monday, September 15, 2008 1:06 PM To: [email protected] Subject: Re: [ADVANCED-DOTNET] problem to insert value in dropdownlist on formView control Thanks jim, do you mean something like this? dropDownList1.Items.Insert(0, new ListItem("Add New2", "999")); nonworking working also. -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of Graf, Jim Sent: Monday, September 15, 2008 8:53 PM To: [email protected] Subject: Re: [ADVANCED-DOTNET] problem to insert value in dropdownlist on formView control You have to add after the bind and do it every time the list is rebound -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of Graf, Jim Sent: Monday, September 15, 2008 12:50 PM To: [email protected] Subject: Re: [ADVANCED-DOTNET] problem to insert value in dropdownlist on formView control Look at the insert method -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[email protected]] On Behalf Of lior levi Sent: Monday, September 15, 2008 12:31 PM To: [email protected] Subject: [ADVANCED-DOTNET] problem to insert value in dropdownlist on formView control Hello, I'm using the SqlDataSource to insert value in dropdownlist, but i want to add a -- Add New -- at the end of the list, but can't find a way to make it. It works very well if I delete the SqlDataSource of the DropDownlist... maybe the inserted item is overwrited by the SqlDataSource !!? protected void FormView1_ItemCreated(object sender, EventArgs e) { if (FormView1.CurrentMode == FormViewMode.Insert) { DropDownList dropDownList1; dropDownList1 = (DropDownList)FormView1.FindControl("DDL_ca"); if (dropDownList1 != null) { dropDownList1.SelectedIndexChanged += new EventHandler(DDL_ca_SelectedIndexChanged); SqlDataSourceActions.ConnectionString = "ConnectionString"; dropDownList1.Items.Add(new ListItem("Add New1", "999")); dropDownList1.DataSourceID = "SqlDataSourceActions"; dropDownList1.DataValueField = "CA_code"; dropDownList1.DataTextField = "CA_desc"; dropDownList1.DataBind(); dropDownList1.Items.Add(new ListItem("Add New2", "999")); } } } Any Ideas? =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor. http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com