Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:54:40+00:00 2026-06-07T16:54:40+00:00

I’m newbie to Visual Studio 2010 .NET 4.0 Dynamic Data. Now I’m trying to

  • 0

I’m newbie to Visual Studio 2010 .NET 4.0 Dynamic Data. Now I’m trying to do a simple dropdown list for my Web site (written in C#).

I’ve got a field called protocol (as in TCP-protocol). I want the user to be able to choose one of static values.
In olden days with classic ASP and HTML I would have used something like this:

<form name=form1 method="POST" action="./insert.asp">
...
     <select name="PROTOCOL" size="1">
        <option value="https" selected>https
        <option value="sftp">sftp
        <option value="ftps">ftps
     </SELECT>
...
</form>

… and then handled the database in the ./insert.asp.

So far I’ve found instruction on how to do this in Visual Studio 2008 (.NET 3.5), but this doesn’t work in WS2010 and .NET 4.0:
http://csharpbits.notaclue.net/2008/07/dynamic-data-and-field-templates-your.html

Following the instructions in http://www.asp.net/web-forms/videos/aspnet-dynamic-data I’ve figured that in order to customize my fields I need to

  • Create file for my custom code in the App_Code folder (MyService.cs).
  • Create a ‘public partial class’ for my MS-SQL -table (service).

Here’s my (¿pathetic?) effort (App_Code/MyService.cs):

// MyService.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.Web;
using System.ComponentModel;

   [MetadataType(typeof(serviceMetadata))]
    public partial class service
    {

    }

    public class serviceMetadata
    {
        [EnumDataType(typeof(ProtocolType))]
        public object protocol { get; set; }

    }

   public enum ProtocolType
    {
        https,
        sftp,
        ftps
    }

This builds ok, but running it ends with “ArgumentException was unhandled by user code / The value passed in must be an enum base or an underlying type for an enum, such as an Int32.” message in \DynamicData\FieldTemplates\Enumeration.ascx.cs -file.

Help appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:54:41+00:00Added an answer on June 7, 2026 at 4:54 pm

    OK, since nobody has tried to answer this, I’ll try to answer my own question.

    Seems to me that there is not out-of-the-box method for this problem. However, in my mind (please do correct me if I’m wrong) there are three possible solutions for this problem:

    1. Change the database structure
      • Add new table, which contains the protocols and link it to service table:
        • Add a protocols -table containing these fields.
          • protocols.id (int, Primary Key)
          • protocols.protocol (char(10))
      • Delete (drop) the service.protocol -field
      • Add a service.protocols_id -field.
      • Make relation: FK:service.protocols_id –references–>> PK:protocols.id
    2. Change the service.protocol -field to numeric (int)

      • Replace the protocol names with numeric values (1, 2, 3)
      • Change the enum -code:

        public enum ProtocolType 
        {
            https = 1,
            sftp = 2,
            ftps = 3
        }
        
      • More on the subject: http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.enumdatatypeattribute.aspx

    3. Create your own FieldTemplate

      • Requires in-depth knowledge on .NET 4.0, DynamicData, C# (or whatever your programming language is), data context (=classes to represent database entities)
      • You can get started by right-clicking the …\DynamicData\FieldTemplates\ -folder, choose DynamicDataField, rename as MyDropDownList, click Add.
      • More on the subject: http://msdn.microsoft.com/en-us/library/cc488522.aspx

    Comments are welcome.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.