Hey guys,
Im not very good at programming but ive a huge project and i needed help on something.
The basic thing is that im making a project for a doctors hospital
Now im working on the prescrption and i wanted the doctor to be able to select the patient from a list of patients which are displayed in a drop down list. From the drop down list, the address(street suburb and postcode) are then displayed as the value is changed. I want the values to be displayed in a textbox or a label,but im not sure how too.I think its somethng to do with code, bt i have no clue on how to code in vb:S
Can someone please help?
Ive got the code here:

<!--This is the Data source for the patient Name to display-->
    <asp:SqlDataSource ID="SqlDataSource12" runat="server" 
        ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
        SelectCommand="SELECT [patient_ID], firstname + ' ' + lastname AS name FROM [Patient_table]">
          </asp:SqlDataSource>
      
        Patient Name:
       <asp:dropdownlist ID="patient_IDTextBox" runat="server" DataSourceID="SqlDataSource12" DataTextField="name" DataValueField="patient_ID"/>
       <br/>
      
      <--! this is the data source for patient details i.e address to display-->
     <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
        ConnectionString="<%$ ConnectionStrings:projectConnectionString %>" 
        SelectCommand="SELECT patient_ID, st_address,suburb,postcode FROM Patient_table WHERE patient_ID=@patid ">
      <SelectParameters>
     <asp:ControlParameter Name="patid" Type="int32" ControlID="patient_IDTextBox" PropertyName="SelectedValue"/>
      </SelectParameters>   
      </asp:SqlDataSource>
 
Suburb:
<asp:Label ID="patid1" runat="server" DataSourceID="SqlDataSource3" Text='<%# Eval("st_adress") %>' /><br />
 Street Address: 
 <asp:Label ID="patid2" runat="server" DataSourceID="SqlDataSource3" Text='<%# Eval("suburb") %>' /><br />
 Post Code:
<asp:Label ID="patid3" runat="server" DataSourceID="SqlDataSource3" Text='<%# Eval("postcode") %>' />

Recommended Answers

All 2 Replies

From the sounds of what you are trying to do, I would suggest you try adding an OnSelectedIndexChanged property to your dropdown list. This property will allow you to call a method that can be used populate a textbox or label.

For example, I used a drop down box like this :

<asp:DropDownList ID="filter_list" TabIndex="2" OnSelectedIndexChanged="make_Visible" AutoPostBack="true" runat="server">
            <asp:ListItem Text="Select Filter Type" Value="0" Selected="True" />
        </asp:DropDownList>

when make_Visible was called, another control was displayed and filled with the data I needed for it to be effective. The AutoPostBack is needed to force a postback and allow the server to run the code needed to respond to the change in the dropdown list value.

Hope that helps!

Yes..I tried that out.It worked:) Thanks:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.