![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to copy dropdownlist to each other? I need to know how to copy one DropDownList to another in a single line. I have a class method that builds a DropDownList object at runtime. This object is then returned to the calling ASPX page. I tried: dropNames = CommonTools.LoadNames(); //returns DropDownList object LoadNames returns a populated DropDownList object. But the rendered list is blank even though the debugger says that the class did return with the correct object. The only time I can get the DropDownList to display its content is: dropNames .DataSource = CommonTools.LoadNames().Items Even then I get the Text options, but the Values are just the same as the text and not what the “values” the class returned. How can I accomplish this? Im trying to avoid a FOREACH |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to copy dropdownlist to each other? What possible reason could there be for *needing* to do this in a single line of code? "JP" <JP@xxxxxx> wrote in message news:B3D28738-C6CA-4F15-A171-0B596FCCEF7F@xxxxxx Quote: >I need to know how to copy one DropDownList to another in a single line. > > I have a class method that builds a DropDownList object at runtime. This > object is then returned to the calling ASPX page. I tried: > > dropNames = CommonTools.LoadNames(); //returns DropDownList object > > LoadNames returns a populated DropDownList object. But the rendered list > is > blank even though the debugger says that the class did return with the > correct object. > > The only time I can get the DropDownList to display its content is: > > dropNames .DataSource = CommonTools.LoadNames().Items > > > Even then I get the Text options, but the Values are just the same as the > text and not what the “values” the class returned. > > > How can I accomplish this? Im trying to avoid a FOREACH > |
My System Specs![]() |
| | #3 (permalink) |
| Vista Business x64 | Re: How to copy dropdownlist to each other? For a Winforms App a single line: comboBox2.DataSource = comboBox1.Items; For a Web App two lines: this.DropDownList2.DataSource = this.DropDownList1.Items; this.DropDownList2.DataBind(); EDIT: oops, never mind, the values are copied as strings equal to the text value in the web app... |
My System Specs![]() |
| | #4 (permalink) |
| Vista Business x64 | Re: How to copy dropdownlist to each other? How's this (4 lines, but no for loop): this.DropDownList2.DataTextField = "Text"; this.DropDownList2.DataValueField = "Value"; this.DropDownList2.DataSource = this.DropDownList1.Items; this.DropDownList2.DataBind(); |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Add Event Handler to dynamic DropDownList?????? | .NET General | |||
| dropdownlist databinding problem | .NET General | |||
| copy-item changing files attributes on network copy failures | PowerShell | |||
| vista can't copy large files? another XP file-copy bug? | Vista General | |||
| Issue need your help: How to control combox/dropdownlist in web page? | PowerShell | |||