How do I remove data from the right side of a number in a text box used for an Insert?

Posted on 2008-11-19
Last Modified: 2013-12-17
I have a drop down list that contains hard coded numbers i.e 1230PAN, 1230PRO, 5801PDV etc. These numbers can be successfully Inserted into my db. I now need to add a description to each 'AccountNo' but do not want it to be Inserted along with the number. How can I go about inserting the 7characters of the Account No without including the description?


<asp:DropDownList ID="ddlAccountNo" runat="server" Style="position: static" Width="158px" Visible="False">


                            <asp:ListItem Value="--SELECT ACCOUNT--" Style='color:red'></asp:ListItem>
















string commandString4 = "INSERT INTO P_AMASTER(ACCOUNTNO) " +

                    "Values (:AccountNO)";


OracleParameter accountParam = new OracleParameter(":AccountNO", OracleType.VarChar, 200);

            accountParam.Value = ddlAccountNo.SelectedValue;


Open in new window

Question by:dwezil
    LVL 53

    Expert Comment

    Can you give an example of what you exactly want (the value you put in, and the thing you want)

    String..::.Substring Method (Int32, Int32)
    accountParam.Value = ddlAccountNo.SelectedValue.ToString().SubString(0,7)

    Author Comment

    1230PAN Displays - PANORAMA

    I only want the 1230PAN part, the problem is the string length differs per account number because the descriptions are different in length
    LVL 53

    Accepted Solution

    Is your string that you want always 7 chars ?
    If yes: accountParam.Value = ddlAccountNo.SelectedValue.SubString(0,7)

    Is your string always left from a specific character (for example a space)
    If yes: accountParam.Value = ddlAccountNo.SelectedValue.SubString(0, ddlAccountNo.SelectedValue.IndexOf(" "))
    LVL 2

    Expert Comment

    I am not sure i understood your problem correctly, but if u want to have a text for each item and when updating u want to upadte a value then u can use dropdownlist DataValueField and Datatextfield properties.

    Author Closing Comment

    Thanks buddy

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    730 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now