?
Solved

adding an "Other" option to a dropdown list

Posted on 2011-09-26
8
Medium Priority
?
199 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 33

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 33

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 33

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 33

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 33

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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

When installing SharePoint 2010 RTM I came across a strange error, I was getting timeouts during the installation. I searched the web and found the best solution to be found here (http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010genera…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

771 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