• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

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?
aspx. DROPDOWNLIST
//////////
<asp:DropDownList ID="ddlAccountNo" runat="server" Style="position: static" Width="158px" Visible="False">
      
                            <asp:ListItem Value="--SELECT ACCOUNT--" Style='color:red'></asp:ListItem>
                            <asp:ListItem>1230PAN</asp:ListItem>
                            <asp:ListItem>1230PRO</asp:ListItem>
                            <asp:ListItem>1230SPE</asp:ListItem>
                            <asp:ListItem>1230MDV</asp:ListItem>
                            <asp:ListItem>1240RDK</asp:ListItem>
                            <asp:ListItem>1240SAS</asp:ListItem>
                            <asp:ListItem>1230TRM</asp:ListItem>
                            <asp:ListItem>5801PDV</asp:ListItem>
                            <asp:ListItem>5801SAS</asp:ListItem>
                            <asp:ListItem>1230CUS</asp:ListItem>
                            <asp:ListItem>1230CUK</asp:ListItem>
                        </asp:DropDownList></td>
////////
INSERT STATEMENT
////////
string commandString4 = "INSERT INTO P_AMASTER(ACCOUNTNO) " +
                    "Values (:AccountNO)";
  
OracleParameter accountParam = new OracleParameter(":AccountNO", OracleType.VarChar, 200);
            accountParam.Value = ddlAccountNo.SelectedValue;
            myCommand4.Parameters.Add(accountParam);

Open in new window

0
dwezil
Asked:
dwezil
  • 2
  • 2
1 Solution
 
DhaestCommented:
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)
http://msdn.microsoft.com/en-us/library/aka44szs.aspx
accountParam.Value = ddlAccountNo.SelectedValue.ToString().SubString(0,7)
0
 
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
0
 
DhaestCommented:
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(" "))
0
 
garavindbabuCommented:
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.
0
 
dwezilAuthor Commented:
Thanks buddy
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now