Jump to content
Sign in to follow this  
p_richardson

!!HELP, PLEASE!!

Recommended Posts

I am trying to have 3 drop down lists (Name, Expertise, Location). Each of these drop down lists have their choices that the user could select and then click on 'submit button'. When user clicks on that submit button... (lets say Mr Jones from the 'Name drop down list') ... it will come with Mr Jones and his expertise and his location. The information is stored in a database.When the information is recieved... I want it to display in a table with 3 coloums (Name, Expertise, Location) and Mr Jones' information to be displayed in the 3 coloums accordingly.Please can someone help me to be able to achieve this.I would be most appreciated if someone could tell me what i need to do and in what order I should do this in.Alternatively could someone please tell me what and where I have gone wrong in my attempt to do this from the code below:<%@ Page Language="VB" %><%@ Register TagPrefix="wmx" Namespace="Microsoft.Saturn.Framework.Web.UI" Assembly="Microsoft.Saturn.Framework, Version=0.5.464.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %><script runat="server"> Sub btnExpertise_Click(sender As Object, e As EventArgs) Function GetExpertise() As System.Data.SqlClient.SqlDataReader Dim connectionString As String = "server='localhost'; user id='sa'; password='********'; Database='Specialists'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [specialists].[Name], [specialists].[Expertise], [specialists].[secondary "& _ "Expertises], [specialists].[Location] FROM [specialists]" Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection) sqlConnection.Open Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) Return dataReader End Function End Sub Function SpecialistName() As System.Data.SqlClient.SqlDataReader Dim connectionString As String = "server='localhost'; user id='sa'; password='password'; Database='Specialists'" Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString) Dim queryString As String = "SELECT [specialists].[Name], [specialists].[Expertise], [specialists].[secondary "& _ "Expertises], [specialists].[Location] FROM [specialists]" Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection) sqlConnection.Open Dim dataReader As System.Data.SqlClient.SqlDataReader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection) Return dataReader End Function Sub Page_Load(sender as Object, e as EventArgs) If Not Page.IsPostBack then specialists.DataSource = GetExpertise() specialists.DataBind() End If End Sub Sub expertise_SelectedIndexChanged(sender As Object, e As EventArgs) dgspecialists.DataSource = GetSpecialistsByExpertise(expertise.SelectedItem.Value) dgspecialists.DataBind() End Sub Sub btnName_Click(sender As Object, e As EventArgs) 'Format the data entered by the user and 'append it to the existing contents of lblResults lblResults.Text = "<b>" & _ ddlName.SelectedItem.Text & _ lblResults.Text End Sub Sub btnLocation_Click(sender As Object, e As EventArgs) 'Format the data entered by the user and 'append it to the existing contents of lblResults lblResults.Text = "<b>" & _ ddlLocation.SelectedItem.Text & _ lblResults.Text End Sub Sub DataGrid1_SelectedIndexChanged(sender As Object, e As EventArgs) End Sub Sub ddlExpertise_SelectedIndexChanged(sender As Object, e As EventArgs) Response.Write("<br>Text selected: "& expertise.SelectedItem.Text) Response.Write("<br>Value selected: "& expertise.SelectedItem.Value) End Sub</script><html><head></head><body> <form runat="server"> <p> Search By Specialist's Expertises:      <asp:DropDownList id="ddlExpertise" runat="server" Width="221px" OnSelectedIndexChanged="ddlExpertise_SelectedIndexChanged"> <asp:ListItem Value="<Please Select Expertise>" Selected="True"><Please Select Expertise></asp:ListItem> <asp:ListItem Value="Knee">Knee</asp:ListItem> <asp:ListItem Value="Hip">Hip</asp:ListItem> <asp:ListItem Value="Autologous Chondrocyte Implantation">Autologous Chondrocyte Implantation</asp:ListItem> <asp:ListItem Value="Shoulder">Shoulder</asp:ListItem> <asp:ListItem Value="Foot">Foot</asp:ListItem> <asp:ListItem Value="Ankle">Ankle</asp:ListItem> <asp:ListItem Value="Lumbar Discectomy">Lumbar Discectomy</asp:ListItem> <asp:ListItem Value="Lumbar Fusion">Lumbar Fusion</asp:ListItem> <asp:ListItem Value="lumbar decompression">lumbar decompression</asp:ListItem> <asp:ListItem Value="Calcaneum">Calcaneum</asp:ListItem> <asp:ListItem Value="Proximal Humerus">Proximal Humerus</asp:ListItem> <asp:ListItem Value="Scaphoid">Scaphoid</asp:ListItem> <asp:ListItem Value="Distal Radius">Distal Radius</asp:ListItem> <asp:ListItem Value="Forearm">Forearm</asp:ListItem> <asp:ListItem Value="Distal Humerus">Distal Humerus</asp:ListItem> <asp:ListItem Value="Humerus">Humerus</asp:ListItem> <asp:ListItem Value="Colles Fracture">Colles Fracture</asp:ListItem> <asp:ListItem Value="Nerve Repair">Nerve Repair</asp:ListItem> <asp:ListItem Value="Tetraplegia Surgery">Tetraplegia Surgery</asp:ListItem> </asp:DropDownList>  <asp:Button id="btnExpertise" onclick="btnExpertise_Click" runat="server" Text="Find"></asp:Button> <br /> Search By Specialist's Name:            <asp:DropDownList id="ddlName" runat="server" Width="287px"> <asp:ListItem Value="<Please Select Name>" Selected="True"><Please Select Name></asp:ListItem> <asp:ListItem Value="Prof. James Richardson">Prof. James Richardson</asp:ListItem> <asp:ListItem Value="Mr. Simon Roberts">Mr. Simon Roberts</asp:ListItem> <asp:ListItem Value="Mr. JayTrivedi">Mr. JayTrivedi</asp:ListItem> <asp:ListItem Value="Mr Nilesh Makwana">Mr Nilesh Makwana</asp:ListItem> <asp:ListItem Value="Mr Cormac Kelly">Mr Cormac Kelly</asp:ListItem> <asp:ListItem Value="Mr David Ford">Mr David Ford</asp:ListItem> <asp:ListItem Value="Mr Stuart Hay">Mr Stuart Hay</asp:ListItem> <asp:ListItem Value="Mr George Tselentakis">Mr George Tselentakis</asp:ListItem> <asp:ListItem Value="Mr Simon Pickard">Mr Simon Pickard</asp:ListItem> </asp:DropDownList>                      <asp:Button id="btnName" onclick="btnName_Click" runat="server" Text="Find"></asp:Button> <br /> <!-- Insert content here -->Search By Location of Specialists:     <asp:DropDownList id="ddlLocation" runat="server" Width="287px"> <asp:ListItem Value="<Please Select Location>" Selected="True"><Please Select Location></asp:ListItem> <asp:ListItem Value="Oswestry">Oswestry</asp:ListItem> <asp:ListItem Value="London- All">London- All</asp:ListItem> <asp:ListItem Value="London City">London City</asp:ListItem> <asp:ListItem Value="London- West">London- West</asp:ListItem> <asp:ListItem Value="London- North">London- North</asp:ListItem> <asp:ListItem Value="London- East">London- East</asp:ListItem> <asp:ListItem Value="London- South">London- South</asp:ListItem> <asp:ListItem Value="Manchester">Manchester</asp:ListItem> <asp:ListItem Value="Liverpool">Liverpool</asp:ListItem> <asp:ListItem Value="Birmingham">Birmingham</asp:ListItem> <asp:ListItem Value="Newcastle">Newcastle</asp:ListItem> <asp:ListItem Value="Nottingham">Nottingham</asp:ListItem> </asp:DropDownList>                   <asp:Button id="btnLocation" onclick="btnLocation_Click" runat="server" Text="Find"></asp:Button> <br /> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p tabindex="1"> <br /> <br /> <wmx:MxDataGrid id="dgSpecialist" runat="server" Width="524px" AllowSorting="True" Height="135px" DataSourceControlID="SqlDataSourceControl1" AutoGenerateFields="False" DataMember="Specialists" AllowPaging="True" DataKeyField="Name" BackColor="White" BorderColor="#CCCCCC" BorderWidth="1px" CellPadding="3" BorderStyle="None"> <SelectedItemStyle font-bold="True" forecolor="White" backcolor="#669999"></SelectedItemStyle> <ItemStyle forecolor="#000066"></ItemStyle> <FooterStyle forecolor="#000066" backcolor="White"></FooterStyle> <HeaderStyle font-bold="True" forecolor="White" backcolor="#006699"></HeaderStyle> <PagerStyle horizontalalign="Center" forecolor="#000066" backcolor="White" mode="NumericPages"></PagerStyle> <Fields> <wmx:BoundField DataField="Name" SortExpression="Name" HeaderText="Name"></wmx:BoundField> <wmx:BoundField DataField="Expertise" SortExpression="Expertise" HeaderText="Expertise"></wmx:BoundField> <wmx:BoundField DataField="Secondary Expertises" SortExpression="Secondary Expertises" HeaderText="Secondary Expertises"></wmx:BoundField> <wmx:BoundField DataField="Location" SortExpression="Location" HeaderText="Location"></wmx:BoundField> </Fields> </wmx:MxDataGrid> <br />   <br /> <br /> <br /> </p> <p> </p> <p> </p> <p runat="server"> </p> <p runat="server"> </p> </form></body></html>

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...