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
and i have created a ddl based on that data source
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
This is where I am struggling to understand what to do I have tried various ways including the following but none of them work
If someone could point me in the right direction or perhaps show me an example I would be extremely grateful
Regards
Paul
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
Regards
Paul