CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2010
    Posts
    1

    Submitting part of a selected value to a database

    Hi there,
    I am creating a web site within Visual Web Developer. Within one of the pages, I am prefilling a drop down list. It is a a list of weeks and their description, so I have concatenated these 2 fields as one. Thus when the user selects from the list they will see week ID and description, e.g. 1 screening. However, when they click to submit, I only wish to submit the ID to a table within the database. I am looking help as to what code i need to write within the on submit button, in order to only submit first half, i.e. the ID of the slected value, to the database? Is it some sort of case statement?

    thanks

  2. #2
    Join Date
    Apr 2010
    Location
    Scotland
    Posts
    9

    Re: Submitting part of a selected value to a database

    Hi,

    You can give each option in an HTML drop down list an optional value as well as the text that shows in the browser. Something like this should help you:

    <select name="weeks">
    <option value="1">1 screening</option>
    </select>

    In the above example, "1 screening" will show in the gui in the browser but only the value, 1 will be posted when you submit.

    Or, if you are using ASP .NET web form controls then the same can be achieved using:
    <asp: DropDownList ID="weeks" runat="server">
    <asp:ListItem Value="1">1 screening</asp:ListItem>
    </asp: DropDownList>

    So, you don't have to write any custom code in the submit button to extract the id because it is all that will be posted.

    I hope this helps.

    Alan
    www.rapidqualitysystems.com - Taking Code Visualization to New Heights

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured