.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

DropdownList Selection to Populate TextBox

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
I have a dynamically generated dropdownlist, that lists e.g. Company Names. I want to be able to select a particular Company and display associated information e.g. Name, Address, City, State... etc. in text boxes adjacent to the list. I am trying to fire the following code from the dropdownlist "OnSelectedIndexChanged" property, but cannot 1) get the code to fire upon selection, and 2) populate the text boxes... any suggestions are appreciated!! Thanks CODE:     Public Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles Facility.SelectedIndexChanged Dim FacilityAddressDetail As String  Dim FacilityAddress2 As String  Dim FacilityCity As String  Dim FacilityState As String  Dim FacilityZip As String Dim   FacilityAddressDetail = FacilityAddress2 = FacilityCity = FacilityState = FacilityZip =       mySettingsSIC = AppSettings   dgiSelectedIndexChange As DataGridItemFor Each dgiSelectedIndexChange In myDataGrid.ItemsCType(dgiSelectedIndexChange.FindControl("FacilityAddressDetail"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityAddress2"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityCity"), TextBox).TextCType(dgiSelectedIndexChange.FindControl("FacilityState"), TextBox).TextCType(dgiSelec

View Complete Post

More Related Resource Links

Cannot populate the textbox with selection from dropdownlist. Thanks

I am not able to get the selection from dropdown into the detailsview template field during update. 

 <asp:TemplateField HeaderText="SupplierName" SortExpression="SupplierName">
                  <asp:TextBox ID="TextBox1Sup" runat="server"  Text='<%# Bind("SupplierName") %>'  Visible="True"></asp:TextBox>
                  <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" 
                  DataSourceID="AccessDataSource" DataTextField="CompanyName" 
                     DataValueField="CompanyName" AutoPostBack="True"  
                        > </asp:DropDownList>                    
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("SupplierName") %>'></asp:TextBox>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("SupplierName") %>'>&

populate label/textbox from dropdownlist in insert item template


I've been trying to find a solution to my problem for about 2 days now, and have found nothing.  I am new to .net and not really sure how to accomplish this. 

I have 4 tables in a database, Vendors, RepairCos, Cons, ConRepairHistory.   What I'm trying to do is make a page called SendOutForRepair.aspx that has a insert item template where the first control is a dropdownlist that is attached to the Cons table (got this figured out) and is populated with the Serial Number field.  I would like the selection from the dropdownlist to populate the 2nd control (VendorID) that is also from the Cons table.

example record from Cons Table:  Serial number      VendorID
                                                      508585                     1

so when 508585 is selected in the dropdownlist, it would populate VendorID with 1 (this is my issue)

once this happens, the user would fill in the other fields (hours, issue, repairco (al

ASP.NET Multiple Selection DropDownList with AJAX HoverMenuExtender

Recently, I was looking for a multiple selection dropdownlist control for my new project. After spending some time researching for it, I decided to put together all my finding in one web user control. This web user control consists of an ASP.NET AJAX HoverMenuExtender, JavaScript, StyleSheet and CheckBoxListExCtrl . The final product will work with or without a MasterPage and you can drag and drop more than one instances of the control on to the page.

how to bind Dropdownlist based on textbox values



I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this

search multiple words into textbox and populate all records in gridview related those keywords


I have a textbox and a gridview which is bound to a table

what I want to achieve is a solution where lets say there are two records - e.g. "1. Book and 2. Red", i want a user to type in those words and the gridview shows the results as followed;

1. Book

2. Red

I have set up the sql data source and everything and my like operator is this...

LIKE '%' + @record + '%'

how can I solve this problem?

Questions about setting dropdownlist selection programatically

I don't understand some things about setting the current selection of dropdownlists from code. I have a dropdown list of people's names where the Value is a Person_ID.  This gets loaded from SQL, and I added an Item which is "Please select..." to the top of the list and gave it a value of 0.  AppendDataBoundItems is true.   If I want to select an item from code can I use dropdownlist.SelectedValue=8 (for example)? Do I also have to set the SelectedItem.Text or does tha above do that for me? Can I instead set the SelectedIndex to some number if I happen to know it?  Will that set the SelectedValue and SelecteItem for me? If I want to set the list back so that nothing is selected (and Please select... shows) should I set SelectedIndex=0?  Is that the same as setting SelectedValue=0 in this case (since "Please select" has a value of 0)? I guess I'm confused on which of these 3 properties I should be using, to select an item (or deselect all items) in the list, using code. Thanks.

How to use parameter from Dropdownlist to populate Rep. Table

I successfully have populated a dropdownlist from a database. Now I need to create a sort of a Master/Detail situation - based on the selection in the DropDownlist, I need to populate a Repeating table. I just can't find any examples or tutorials on how to do this. I've tried stuff till my fingers were bleeding. Can someone help me figure this scenario out, please?

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

Dropdownlist selection

Hi All,          I have 4 columns in same table(Region,Site,Compaign,LOB).I should display each in seperate dropdownlist.Based on selection of region i should display region related sites based on Sites i should display compaign and finally LOB.Can anyone send me sample code on how to acheive this using selected index changed event with ajax extension not ajax toolkit.I think i should use update panel for all 4 dropdownlists.Is that correct.    

DataList/FormView won't populate DropdownList

I have a ddl inside the formview that I can't figure out how to wire up properly. The formview contains detail info, but the ddl needs to list the entire set to items. Then I want the ddl's selected value be set from the recordset intended  for the formview. I think it's just a timeing issue s I would like your help. Thanks, - EJM. Here my code somewhat reduced to save space...<asp:DataList Width="700" ID="DlMembers" runat="server" DataKeyField="Ident" OnItemCommand="DlMembers_ItemCommand" OnDeleteCommand="DlMembers_DeleteCommand" > <HeaderTemplate> <table border="1" cellpadding="2" cellspacing="0"> <tr align="left" valign="top"> <th nowrap>First Name</th><th nowrap>Last Name</th><th nowrap>Address</th><th nowrap>Email</th><th nowrap>Home Phone</th><th nowrap>Work Phone</th><th nowrap>Cell Phone</th><th nowrap>Position</th><th nowrap>Admin</th><th nowrap>Comments</th><th> </th><th> </th></tr></HeaderTemplate><ItemTemplate>

Populate DropDownList in InsertItemTemplate after insert

I thought this one would be easy, but no go. What I am trying to do is the following: I have two DropDownLists in my InsertItemTemplate, each bound to its own datasource. After the fields in this form have been filled out and the ItemInserting event fires, I rebind the ListView to its datasource, but the DropDownLists turn out empty. I tried to bind them in the ItemInserting event and it seems they get filled, but nothing shows up in them when the page loads. I also tried to fill them in the ItemDataBound event, but the e.Item.ItemType == InsertItem doesn't do it. What is the solution?

How do I populate a Textbox with the current system date and time?

Hello, all! First I am a complete newbie and I have a project that I need help with. I am building a Windows form application to keep track of servers and their last maintenence date. I have a simple one table SQL Express database (empty). One of my rows is set up to store the date and time. But first, I need to know how to auto populate the system date and time to a TextBox control everytime someone opens the application. I have tried using the System.DateTime method in the Textbox event properties as a string but I am doing something wrong. Thanks in advance for your help and guidence!

Using Rules to populate a textbox based on other values.


I am building a web-friendly form in Infopath (little new to the software)...

I have been able to hook up my form to my SharePoint and pull in user data so I can pre-populate various fields.

One field is not in our Profile services (nor Active Directory).  I'll call it Company Code.

But you can determine Company Code by checking the Company and Department.

Something like:

Company = "ABC", Department = "123" then Code = "XCV"
Company = "ABC", Department = "456" then Code = "VCX"


Since I am successful pulling the Company and Department from the Webservice.

I figured I build a text-box and put 30 or so rules on it to analyze the contents of Company and Department to determine what should be in the text-box.
So I used Conditions to check the Comany and Department and then the rule set the contents of the Company Code box.

However it seems as though the rules never run. 

And I got to thinking, when DOES the rule know when to run?  I don't see an "onchange" event or anything (trying to avoid code for web-friendly anyways) - so....

I do have the Company and Department fields populate immediately when the form is opened, but is that early enough for the rules?

Do the rules have to manually tri

Text selection in textbox on mouse over


I am having a Textbox and want to selcted text with perticular format on mouse over.

So if my text in textbox is "This person <<PersonName>> has a good experience of <<Year>> in <<Technology>>". Now if I put my mouse over <<PersonName>> or <<Year>> or <<Technology>>, only this text (<<PersonName>>, etc) should be highlighted. 

How can I start implementing this as I know Textbox in WPF/Silverlight doesn't provide this behavior.

Populate dropdownlist in Edit mode programatically


I'm trying to programatically populate some dropdownlists inside a formview in EDIT mode, like this below.

 Dim FVM As String = FormViewMemberProfile.CurrentMode.ToString

        If FVM = "Edit" Then

            Dim ddlDays As DropDownList = CType(FormViewMemberProfile.FindControl("ddlDays"), DropDownList)
            Dim ddlYears As DropDownList = CType(FormViewMemberProfile.FindControl("ddlYears"), DropDownList)

            Dim i As Integer = 1

            For i = 1 To 31

            Dim k As Integer

            For k = 1930 To 2008

        End If

I orginally had this running as part of the pagelaod event, but I'm thinking that b/c the page loads first, it doesn't populate the fields in EDIT mode until after the data is saved, and then page is reloaded. Now it knows it's in "Edit" mode. Am I thinking clearly here? Not sure if this is the order of things... Anyhow...

So I thought I should just use a formview_modechanged (or similar event) so when the user switches modes, it populates the fields - but I'm not sure which event I should use. I've tried "Modechanging", "modechanged", "prer

Howto add selected item from dropdownlist to a textbox on the same form?


 I have been trying to figure out what the proper method is to be able to have a dropdownlist on the same form that holds a number of textboxes for properties. I am using a strongly typed typed view which was generated by the Visual Studio IDE so it contains textboxes for all of the properties of my strongly typed class.  The class has a few properties that can have a set of possilbe answers; I'd like to displat those possible answers in a dropdownlist and then when the user fills in the form and clicks the submit button the selected item would be transferred to the correct property. I have a solution but think there must be a better solution out there and was wondering if anyone might point me in the right direction.

So say I have a model with 3 properties, FirstName, LastName. and MaritalStatus.

If I generated a view for this then I'd get an aspx file with the following:


    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>

            <div class="editor-label">
                <%: Html.LabelFor(model => model.FirstName) %>

DropDownList selection doesn't show


I've got two DropDownLists that are filled using a couple of SqlDataSources, like so:

    <asp:SqlDataSource ID="dsCategories" runat="server" 
    ConnectionString="<%$ ConnectionStrings:EPiServerDB %>" 
    SelectCommand="img_GetCategories" SelectCommandType="StoredProcedure">
            <asp:Parameter DefaultValue="1" Name="CountryID" Type="Byte" />
    <asp:DropDownList ID="categories" runat="server" AutoPostBack="True" 
    DataSourceID="dsCategories" DataTextField="Translation" 
    DataValueField="CategoryID" Width="220px">
    <asp:SqlDataSource ID="dsSubcategories" runat="server" 
    ConnectionString="<%$ ConnectionStrings:EPiServerDB %>" 
    SelectCommand="img_GetSubcategories" SelectCommandType="StoredProcedure">
            <asp:Parameter DefaultValue="1" Name="CountryID" Type="Byte" />
            <asp:ControlParameter ControlID="categories" DefaultValue="" Name
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend