Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

adding an "Other" option to a dropdown list

Posted on 2011-09-26
8
Medium Priority
?
201 Views
Last Modified: 2012-05-12
looking for a bit of advice on the structure of my form...

I have a dropdown with 3 or 4 hard coded values, and I want to add an "Other" option where if selected, a textbox would appear below it where the could enter an a new option. When they then click the SAVE button, I want to be able to save that new option. Obviously, I would need to keep all of the options stored somewhere, I was just wondering what the common practice for this scenario would be. I don't expect more than 10 or so options to ever be added, so would saving it to a list be overkill, or would it be better to save it directly to an xml document and keep that somewhere on the site? if thats the way to go, I'd love to see some examples on how to do this via VB.NET, as I have a custom save function written in VSTA to handle the form saves.
0
Comment
Question by:Big Monty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 14

Expert Comment

by:abhitrig
ID: 36712418
Considering Secondary DataSources are lost, you have the following options:
1. Store the data in SP list
2. Store in DB
3. Store it an XML file.

I would recommend to use a SP list as it will be relatively easy to manage it from Infopath.
0
 
LVL 34

Author Comment

by:Big Monty
ID: 36717829
i've decided to use an xml file, do you know of any tutorials or online examples that would help me write to it? I know how to read from it, just not store the newly added option in it.
0
 
LVL 14

Expert Comment

by:abhitrig
ID: 36718268
I son't think you can save secondary datasources (which you are using to get the xml)
So you have two options:

1. Create a webservice to modify the xml and then call the webservice from IP
2. Use C# code to modify the xml directly. This will be similar to ASP.NET programming where you will edit the xml on the save event of the IP form.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Author Comment

by:Big Monty
ID: 36718293
My apologies I should have been more clear. I want to be able to do this via code as I have a custom save function already in place and need to add this to it. I prefer FB.net but c# would help as well.
0
 
LVL 14

Accepted Solution

by:
abhitrig earned 1500 total points
ID: 36718662
0
 
LVL 34

Author Comment

by:Big Monty
ID: 36719255
these look good, i'll check these out more in depth and get back to you tomorrow.
0
 
LVL 34

Author Comment

by:Big Monty
ID: 36913236
so, after playing around with it a bit, i got it working somewhat. I can get it to save to my local disk, but not on the server. In order to open up the file, I needed to pass the current users credentials over, which I did below. My problem now is that the very last line of code throws an error "Invalid URI". It looks like the save command won't accept a url as a parameter, is there any way around this?
Dim resolver As XmlResolver = New XmlUrlResolver
            resolver.Credentials = System.Net.CredentialCache.DefaultCredentials

            'Dim settings As XmlReaderSettings = New XmlReaderSettings
            'settings.XmlResolver = resolver
            'Dim reader As XmlReader = XmlReader.Create("http://some sharepoint url/Dev/Shared%20Documents/vendors.xml")

            Dim reader As XmlTextReader = New XmlTextReader("http://some sharepoint url/Dev/Shared%20Documents/vendors.xml")
            reader.XmlResolver = resolver

            Dim xd As XmlDocument = New XmlDocument
            xd.Load(reader)

            Dim cr As String = System.Environment.NewLine
            Dim newPerson As String = _
                "<Vendor value=""some value"" /> "

            ' Create a new XmlDocumentFragment for our document.
            Dim docFrag As XmlDocumentFragment = xd.CreateDocumentFragment()

            ' The Xml for this fragment is our newPerson string.
            docFrag.InnerXml = newPerson

            ' The root element of our file is found using
            ' the DocumentElement property of the XmlDocument.
            Dim root As XmlNode = xd.DocumentElement

            ' Append our new Person to the root element.
            root.AppendChild(docFrag)

            ' Save the Xml.
            xd.Save("http://some sharepoint url/Dev/Shared%20Documents/vendors.xml")

Open in new window

0
 
LVL 34

Author Closing Comment

by:Big Monty
ID: 36962498
this got me going in the right direction, but am still having problems with permissions
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
When using a search centre, I'm going to show you how to configure Sharepoint's search to only return results from the current site collection. Very useful when using Office 365 with multiple site collections.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question