Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing data from a dropdown list to textboxes

Status
Not open for further replies.

kiwieur

Technical User
Apr 25, 2006
200
GB
Hi People,

I am really new to asp.net and I am struggling to get the following to work.

I have created a data source
Code:
   <asp:AccessDataSource ID="Enquiries" runat="server" 
        DataFile="~/App_Data/EnquiryApp_BE.mdb" 
        SelectCommand="SELECT companynumber, name, street, city, country, zipcode, companynumber & ' :  ' & name AS Customer FROM tblEQ_CompanyDetails ORDER BY name ASC">
    </asp:AccessDataSource>


and i have created a ddl based on that data source
Code:
<asp:DropDownList ID="CustomerDetails" runat="server" DataSourceID="Enquiries" 
        DataTextField="Customer" DataValueField="companynumber" Height="20px" 
        Width="350" Font-Size="Small"  AutoPostBack="True">
</asp:DropDownList>

I then have a table that contains some text boxes and what I would like is that the textboxes are populated from the data source based on the value selected in the ddl
Code:
<table width="30%" border="1" align="center" cellpadding="1" cellspacing="1" bgcolor="#ffffff" class="tableborderedges" >
        <tr>
            <td class="TextRightPlain10pxBlack">Customer :</td>
            <td class="TextNormalCapitalized">
                 <asp:TextBox ID="txtCustomer" runat="server"  Text=""></asp:TextBox>    
           </td>
        </tr>
         <tr>
            <td class="TextRightPlain10pxBlack">Address 1 :</td>
            <td>
                 <asp:TextBox ID="txtAdd1" runat="server"></asp:TextBox>
            </td>
          </tr>
         <tr>
            <td class="TextRightPlain10pxBlack">Address 2 :</td>
            <td>
                 <asp:TextBox ID="txtAdd2" runat="server"></asp:TextBox>
            </td>
       </tr>
        <tr>
            <td class="TextRightPlain10pxBlack">Address 3 :</td>
            <td>
                <asp:TextBox ID="txtAdd3" runat="server"></asp:TextBox>
            </td>
  </tr>
         <tr>
            <td class="TextRightPlain10pxBlack">Post Code :</td>
            <td>
                <asp:TextBox ID="txtPostCode" runat="server"></asp:TextBox>
            </td>
     </tr>
         <tr>
            <td class="TextRightPlain10pxBlack">Customer No :</td>
            <td>
                <asp:TextBox ID="txtCustNo" runat="server"></asp:TextBox>
                 
            </td>
        </tr>
 
        </table>

This is where I am struggling to understand what to do I have tried various ways including the following but none of them work

Code:
Protected Sub CustomerDetails_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CustomerDetails.SelectedIndexChanged
        txtCustomer.Text = CustomerDetails.DataValueField("name").ToString
        txtAdd1.Text = CustomerDetails.DataValueField("name").ToString
        txtAdd2.Text = CustomerDetails.DataValueField("name").ToString
        txtAdd3.Text = CustomerDetails.DataValueField("name").ToString
    End Sub

If someone could point me in the right direction or perhaps show me an example I would be extremely grateful

[ponder][ponder]



Regards

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top