Avatar of jgoodale
jgoodale
Flag for United States of America asked on

Test for min value from a datasource

What is the best way todo this:

I'm binding the results of stored procedure to a gridview in the following code:

 gvLocations.DataSource = dropOffContext.selectDropOffLocationsByZip(latitude, longitude)

Open in new window


What I would like todo is update a panel (pnlMailBack) with some code if the first result has a value >25 in a particular field.

Thanks,

James.
Visual Basic.NETASP.NETProgramming

Avatar of undefined
Last Comment
jgoodale

8/22/2022 - Mon
Nasir Razzaq

Does it return a datatable?

You can do something like below

Dim dTable As DataTable =  dropOffContext.selectDropOffLocationsByZip(latitude, longitude)

If dTable.Select("fieldname > 25").Count > 0 Then
   'Code to do what you want
End If
gvLocations.DataSource = dTable
jgoodale

ASKER
This is the whole block

Private dropOffContext As dataEntities
dropOffContext = New dataEntities()
            Using dropOffContext
                gvLocations.DataSource = dropOffContext.selectDropOffLocationsByZip(latitude, longitude)
                gvLocations.DataBind()
            End Using

Open in new window


Nasir Razzaq

Entity Framework? Beyond my knowledge.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
jgoodale

ASKER
I'm trying to get the min value of the distance field from the database:

            Using dropOffContext
                Dim temp = dropOffContext.selectDropOffLocationsByZip(latitude, longitude)
                gvLocations.DataSource = temp
                gvLocations.DataBind()

                [b]Dim test = temp.FirstOrDefault.distance.Value[/b]

            End Using

Open in new window



Any Ideas?

I'm getting the following error:

The result of a query cannot be enumerated more than once.
ASKER CERTIFIED SOLUTION
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
jgoodale

ASKER
non of the answered worked.