Advertisement

08.30.2007 at 12:53PM PDT, ID: 22798437
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

5.8

Add extra column to dataset table in asp.net vb.net and bind to repeater

Asked by jumpseatnews in Microsoft Visual Basic.Net, Programming for ASP.NET, Visual Studio

Tags: , ,

Hi,

I'm trying to figure out how to add an extra row to my dataset so that I can bind to a repeater.   I'm querying SQL for a list of records based on a Zip Code search.  A function that I have returns a value called 'Distance'.  I need this to appear next to the listings.

My Code is here:

<script runat="server">
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        ' ----------- STEP 1: GET LONGITUDE AND LATITUDE OF THE USER'S PROVIDED ZIP CODE -----------
        Dim DBConnection As SqlConnection
        Dim DBAdapter As SqlDataAdapter
        Dim DBDataSet As DataSet
        Dim SQLString As String
        DBConnection = New SqlConnection(ConfigurationManager.AppSettings("apdtConnect2"))
        SQLString = "SELECT Latitude, Longitude FROM ZIPCodes WHERE ZIPCode = '92352'"
        DBAdapter = New SqlDataAdapter(SQLString, DBConnection)
        DBDataSet = New DataSet
        DBAdapter.Fill(DBDataSet, "ZIPCodes")
        Dim Latitude As Double = DBDataSet.Tables("ZIPCodes").Rows(0)("Latitude")
        Dim Longitude As Double = DBDataSet.Tables("ZIPCodes").Rows(0)("Longitude")
        lblLatitude.Text = Latitude
        lblLongitude.Text = Longitude
       
        ' ----------- STEP 2: GET LIST OF TRAINERS THAT MATCH ZIP CODE -----------
        ' Check to see if any records exist
        Dim ZIPExists As Boolean = Not (DBDataSet.Tables("ZIPCodes") Is Nothing)
        If ZIPExists Then
            ' Trainers exist, get info about trainers
            Dim Miles As Double = 25
            Dim zcdRadius As New ZIPCodeDownload.RadiusAssistant(Latitude, Longitude, Miles)
            SQLString = "" _
            & "      SELECT * FROM vwTrainerSearchUSRev WHERE" _
            & "            Latitude >= " & zcdRadius.MinLatitude _
            & "            AND Latitude <= " & zcdRadius.MaxLatitude _
            & "            AND Longitude >= " & zcdRadius.MinLongitude _
            & "            AND Longitude <= " & zcdRadius.MaxLongitude _
            & "            AND CityType = 'D'"
            DBAdapter.SelectCommand.CommandText = SQLString
            DBAdapter.Fill(DBDataSet, "ZipCodeOutput")
            Dim zcdDistance As New ZIPCodeDownload.DistanceAssistant()
            Dim thisRow As System.Data.DataRow
            DBDataSet.Tables("ZipCodeOutput").Columns.Add("ShowMiles")
           
            For Each thisRow In DBDataSet.Tables("ZipCodeOutput").Rows
                Dim Latitude2 As Double = CDbl(thisRow("Latitude"))
                Dim Longitude2 As Double = CDbl(thisRow("Longitude"))
                Dim Distance As Double = zcdDistance.Distance(Latitude, Longitude, Latitude2, Longitude2)
                ' THIS IS WHAT RETURNS THE 'DISTANCE' VALUE.  THIS GIVES THE MILES.  I need it to be added to the repeater output on the page.
               
                If Distance <= Miles Then
                    ' Trainer is within distance, so process the info here
                    DBDataSet.Tables("ZipCodeOutput").Rows(2)("ShowMiles") = Distance
                    Repeater1.DataSource = DBDataSet.Tables("ZipCodeOutput")
                    Repeater1.DataBind()
                Else
                    ' Trainer is further than the preference, so do nothing.
                End If
            Next
           
        Else ' Else statement on If ZIPExists
            ' No trainers exist, therefore do nothing
        End If ' End Sub If ZIPExists        
    End Sub ' End Sub Page Load

</script>



AND ON THE PAGE...



    <form id="form1" runat="server">
       <asp:Label ID="lblLatitude" runat="server"></asp:Label> and <asp:Label ID="lblLongitude" runat="server"></asp:Label>
        <br />
        <br />
        <asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
        <%#DataBinder.Eval(Container, "DataItem.City")%>   <%#DataBinder.Eval(Container, "DataItem.ShowMiles")%>  
        <br />
        </ItemTemplate>
        </asp:Repeater>
 
    </form>



Working page of output results is here: http://dev.apdt.com/po/ts/test4.aspx

Basically, i just need to have this list sorted by DISTANCE from shortest to farthest, with the distance displaying NEXT TO EACH CITY.

Much thanks in advance for any advice!

Sincerely,

ChrisStart Free Trial
[+][-]08.30.2007 at 01:00PM PDT, ID: 19803640

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.30.2007 at 01:40PM PDT, ID: 19803970

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.30.2007 at 01:41PM PDT, ID: 19803987

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.30.2007 at 01:44PM PDT, ID: 19804014

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08.30.2007 at 03:43PM PDT, ID: 19804758

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08.31.2007 at 09:31AM PDT, ID: 19809482

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.03.2007 at 09:28AM PDT, ID: 19821310

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Visual Basic.Net, Programming for ASP.NET, Visual Studio
Tags: table, add, dataset
Sign Up Now!
Solution Provided By: jumpseatnews
Participating Experts: 2
Solution Grade: B
 
 
[+][-]09.03.2007 at 08:03PM PDT, ID: 19823011

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 14-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]09.03.2007 at 09:51PM PDT, ID: 19823231

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 14-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2007 at 08:04AM PDT, ID: 19825674

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.07.2007 at 05:56PM PDT, ID: 19851868

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 14-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628