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

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

Who is Participating?
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(" "))
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)
dwezilAuthor Commented:
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
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.
dwezilAuthor Commented:
Thanks buddy
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.