Solved

adding an "Other" option to a dropdown list

Posted on 2011-09-26
8
195 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
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Work Over Net is a new and very powerful collaboration product. With its new easy interface it is becoming very competitive to other similar products like webex and office interactive. WON 2010 have the standard business tools needed for multi-offic…
Before you can digitally sign infopath forms, you must have a digital certificate. Microsoft Certificate Services will need to be enabled on a Windows Server 2008 to facilitate the creation and verification of the digital certifciates on the web ser…

832 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