How to show value in textbox from selected value in Dropdown list

I have two text box, txtbox1 should be from two field for example i have one dropdownlist where i select item and another txtbox2 i want to put value, when i first time to write manually value in txtbox2 in and selected item from ddl i want to result in concatenate from in txtbox1. 

for example
 I have
if not me.ispostback then
Dim cm as new sqlcommand("Select AccMjrid, Names from Accgrp",

me.sqldataAdapter1.fill(Dataset1, "Accgrp")

Me.cmbAccMajID.DataSource = Me.DataSet11.Tables("AccMajor")

Me.cmbAccMajID.DataTextField = "AccName"

Me.cmbAccMajID.DataValueField = "AccMajorID"



Me.cmbAccMajID.SelectedIndex = Me.cmbAccMajID.Items.Count - 1

end if

Private Sub cmbAccMajID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbAccMajID.SelectedIndexChanged


Me.txtAccGrpID.Text = Trim(cmbAccMajID.SelectedItem.Text)  & txtbox2.text

Catch ex As Exception

End Try

I want to display a value in me.TxtAccGrpID.text but display value must be AccMjrID + txtbox2.text
would pls. help me thnx

9/16/2005 11:15:42 AM 93655 articles. 5 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 6

 You can remove this code: ( Unless your if statement does something with it);


Me.cmbAccMajID.SelectedIndex = Me.cmbAccMajID.Items.Count - 1

You could just set the "selecteditemindex" = -1. (No Item selected)

You  could try something like this:

REMEMBER to set the AutoPostBack property of your dropdownlist to True

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

            TextBox2.Text = DropDownList1.SelectedItem.Text()

            TextBox1.Text = DropDownList1.SelectedItem.Value.ToString() & " - " & DropDownList1.SelectedItem.Text()

End Sub

9/16/2005 12:02:06 PM
Thankyou it works because i forget "AutoPostBack" = true
9/18/2005 3:46:36 AM

Similar Artilces:

Displaying values from 3 textboxes automatically after selecting a value from a dropdown list
 The dropdown list is databind to a sqldatasource from the Bike Table.After selecting a bike Name from the dropdown list, the status and rent price will be displayed on the 2 textboxes automatically.Both the status and  rent price values are taken from the same Bike Table.Can anyone help me with this?Thanks. On the selected index change property of the dropdownlist hit the database to get the details (status and rent ) for the selected Item and set the values to the text of textboxes.Hope this helps. Just do this in your OnSelectedIndexChanged event of the ddlSqlCommand cmd =...

I want to display textbox on changing value of dropdownlist or selected value of dropdown list.How could i?
for example i have taken field PF%,PF($)  in dropdown.Onselected value of % i will show textbox.In which u can fill  the value of PF% based on that calulation will be shown in other textbox. But how can i do thta? Not too sure I undertand your question, but if you want to show/hide elements here's a few things you might want to try: You can set the dropdown's autopostback to true and perform all sorts of wonderful serverside stuff, including adding a textbox control (with a certain value) to a container div. If you want to keep things light then use some CSS and ...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

Cascading Dropdown List
Hi, First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists. Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list). Everything is wor...

adding values to the selected value in Dropdown list
 Hi,   I have dropdown box in my page which have some value inherted from the another list box in my page..Now in my second page , i have dropdown box with values and text value and list box... I'll be selecting the one value from the dropdown then i enter the value in text box and click on add button which will add the value in the list box like this i can able to add many if i click on save button for the selected dropdpown item the added values in the listbox should be saved this i add many values for many dropdown item and saved respectivelynow if c...

Dropdownlist selected value passes first value in list no matter what value is selected. why ?
 HI . I have a dropdownlist. Databinds ok but when I must pass a value as a Selected value it always passes the first value in the list even if I select another value. I tried to set the ddl to enableviewstate false but it doesn't change anything. Any ideas ? Code below, thanksLoading the ddl:       productCategories = CatalogAdmin.Admin_Product_Categories_NotIn(productId);        for (int i = 0; i < productCategories.Rows.Count; i++)        {       &...

DropDown list submits first value not the selected value
I am relatively new to programming and am having a problem with a small project that I am working on.  I have a names drop down list that is created from a database.  When the user selects a name and completes the rest of the form and clicks submit.  All of the data they entered is submitted to a different table in that database.  This is workign correctly for all of the data except the drop down.  For some reason the first value in the drop down is being submitted each time.  Here is the code and any help you can give will be appreciated. Public Class final1 ...

Selecting a Value in a Drop Down List Based on the Value of a Textbox
I have a formview control (.NET 2.0/VS2005) in which users enter company contact information.  When a user enters a postal code in the appropriate text box, the territory for that company needs to be calculated and displayed in a territory drop down list. I know how to calculate and retrieve the territory from my SQL Server database, but I can't seem to nail down how to trigger the code and don't want the user to have to click a button. I tried using the OnTextChanged event, but that doesn't seem to be what I want because I need this calculation to be performed pri...

dropdown selected value and dropdown no value saved
 is there any way the selected value is selected already when i try to edit the gridview ... and another thing... when i edit this dropdown.. no value was being saved... what is wrong or missing.. please help... i almost spend two days on this problem...i've read many post about this.. but still i didn;t get it... please help///  <asp:TemplateField HeaderText="Unit" SortExpression="UnitID">                          &...

can i drag the selected value of dropdown list in one web part to another web part
hi, supose i am having time displaying in on webpart can i drag the value of time to another web part and and display the time is: and the value draged from the other webpart so i want to drag the value year and population into antoher web part and according to that the grap must appear i.e what  i exactly want is i must drag some value from one webpart to onother webpart and according to event some thing must happen in another web part   Hi, The problem has been replied in the following post: But from the title you described, do ...

Updating values of dropdown lists on a page based on a textbox value
Hi Everyone,  I know from the title this seems simple however there is a twist.  I have a page that a user fills out to submit feedback on products.  To keep data clean, I let them select the product, type and size based on dropdown lists, but also want to make it so if they type in the barcode, the values for the Product, Type and Size are looked up and populated on the form for them to see it before submitting the form. The form has several textboxes and dropdown lists that update using SQLDataSource connections.  The problem that I'm running ito is ...

Populate a textbox with selected value of a dropdown list
Someone please riddle me this. I have a textbox for a street address. Next to it, I have a button. Next to that, a drop down list of street address suffixes (route, street, etc). If the user selects something from the dropdown list and clicks the button, I want the selected value to be added to the textbox. For example, I type, "Main" then select "Street" and click the button and the textbox should read "Main Street". I can get it to work with a label, but not with a textbox and I have no idea why. Below is the form snippet and the code behind. I am using...

Dropdown list in DetailsView + showing selected value
Ok ... here goes:I have a web form with a details view that shows information in tblCustomers (which holds information on Customers but the State info is StateID - a foreign key). When the user clicks the edit button, I have it so the State is a drop down box populated via a select statement (selecting all from tblState). BUT I want it so that when the user clicks the edit button, the dropdown box show what is in the record in tblCustomers not just the first item on the list.I tried binding but to no avail .... is is possible to bind to something like tblState.StateID?Help!S.R. &nb...

Select value from drop down then other fields shows value in textfield depends on the dropdown.
 Hi,em new in VB.NET & develop a web based transaction which is almost 50% problem is that i have a form of Item properties, which consist on a following fields,1. Item2. Unit3. Old Price4. New Price my client wants that if user select Item from the dropdown then other fields shows value automaticlly on the textfields which is depend on the item name.for example:if user select Colgate from the dropdown then Unit, Old Price and New Price shows in textfeilds seperately.  if u have any code and tutorial about the above example then kindly share with me i will...

Web resources about - How to show value in textbox from selected value in Dropdown list -

Portal:Law/Nominate/Selected article - Wikipedia, the free encyclopedia
Add the article in to a subpage of this portal, such as Portal:Law/Selected article/# , replacing the "#" with the number above the current highest. ...

F8: Facebook’s FbStart Initiative Will Give Selected Developers A $30K Kick-Start
... successful applications is likely a whole lot easier with $30,000 in free tools and services to start off with, and that’s exactly what selected ...

LEGO Shop - The LEGO Technic team has selected the winner... - Facebook
The LEGO Technic team has selected the winner of the Co-Creation Challenge! LEGO will be producing a limited run of 20,000 of this stunning set.... ...

baby365- Grand Doctor Ma Selected Students for iPad on the iTunes App Store
Get baby365- Grand Doctor Ma Selected Students on the App Store. See screenshots and ratings, and read customer reviews.

Selected Cheney Vice Presidential Photographs
... for photos found within these albums are Paul Morse, Karen Ballard, Kimberlee Hewitt, Shealah Craighead, and Chris Greenberg. These selected ...

[iOS Advice] How To Clarify Your Email Replies By Quoting Selected Text - YouTube
Follow me on Twitter: Like my Facebook page: RATE, COMMENT, SUBSCRIBE! :-) ...

Local farmers to sell their fresh dates at selected supermarkets
Fresh dates will be on sale this summer under the label of Local Harvest at selected supermarkets and Spinney's.

Animal of the Day: Lucius Has Been Selected as the U.K.’s ‘Happiest Cat’
He’s got one blue eye, one green eye and a heart of gold. British mobile phone company O2 recently held some “cat auditions” to find “the UK’s ...

Michael Sam becomes first openly gay player selected in an NFL Draft
Defensive end Michael Sam of the University of Missouri became the first openly gay player to be selected in a National Football League Draft ...

Artist facing child pornography charges selected for MCA exhibition
An artist facing child pornography charges has been selected to show work in a prestigious exhibition at the Museum of Contemporary Art Australia. ...

Resources last updated: 1/23/2016 4:34:16 PM