Click here to Skip to main content
15,887,328 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Help in Converting Desktop App to Web App. Pin
Richard Deeming1-Dec-14 1:36
mveRichard Deeming1-Dec-14 1:36 
GeneralRe: Help in Converting Desktop App to Web App. Pin
QuickBooksDev2-Dec-14 23:32
QuickBooksDev2-Dec-14 23:32 
GeneralRe: Help in Converting Desktop App to Web App. Pin
Richard Deeming3-Dec-14 1:28
mveRichard Deeming3-Dec-14 1:28 
GeneralRe: Help in Converting Desktop App to Web App. Pin
QuickBooksDev3-Dec-14 1:33
QuickBooksDev3-Dec-14 1:33 
GeneralRe: Help in Converting Desktop App to Web App. Pin
Richard Deeming3-Dec-14 1:49
mveRichard Deeming3-Dec-14 1:49 
GeneralRe: Help in Converting Desktop App to Web App. Pin
QuickBooksDev3-Dec-14 1:52
QuickBooksDev3-Dec-14 1:52 
QuestionAuto Filter in gridview Pin
umair275624-Nov-14 4:11
professionalumair275624-Nov-14 4:11 
QuestionIf trip type is one thing, show one query; if another, show a different query. This is not working! Pin
samflex24-Nov-14 2:54
samflex24-Nov-14 2:54 
Can someone, please, please come to my rescue again?

I have been struggling with this code since last night.

On the markup page, we have 4 very important dropdownlists.

One dropdownlist has a controlId called tripType.

This dropdownlist has seven values. If a user selects any of the first five values, the dropdownlist with control id of from_city_and_state is visible. The other two dropdownlists, HourlyCharter and LongDistance are hidden.

If user selects Hourly from the tripType dropdownlist, from_city_and_state and LongDistance are hidden and the HourlyCharter dropdownlist is visible.

If Long_Distance dropdownlist is selected, Hourly and from_city_and_state are hidden.

By default, from_city_and_state dropdownlist is visible on page load.

So far, everything to this point works.

The issue is on codebehind.

If a user selects any of the first five values of the tripType dropdownlist as stated earlier, on codebehind, we would like to show one query.

If user selects Hourly value from tripType, we would like to show a different query.

Finally, if user selects Long_Distance, we would like to show yet another query.

So far, I am stuck on the hourly query.

If user selects any of the first 5 values of tripType dropdownlist, the query works flawlessly.

Other than that nothing else works.

Can someone please, please see what I am doing wrong?

Sorry for long explanation.
PHP
<asp:DropdownList ID="tripType" runat="server" class="select " onchange="ShowHideDiv();">
 <asp:ListItem value="">--Select One--</asp:ListItem>
 <asp:ListItem value="one_way_to_airport">One-way trip TO Airport</asp:ListItem>
 <asp:ListItem value="one_way_from_airport">One-way trip FROM Airport</asp:ListItem>
 <asp:ListItem value="round_trip_airport">Round trip involving Airport</asp:ListItem>
 <asp:ListItem value="one_way_no_airport">One-way trip NOT involving Airport</asp:ListItem>
 <asp:ListItem value="round_trip_no_airport">Round trip NOT involving Airport</asp:ListItem>
 <asp:ListItem value="hourly">Hourly/Charter</asp:ListItem>
 <asp:ListItem value="Long_Distance">Long Distance</asp:ListItem>
</asp:DropdownList>


<asp:DropDownList ID="from_city_and_state" runat="server" class="select " >
     <asp:ListItem value="">--Select One--</asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="HourlyCharter" runat="server" class="select ">
     <asp:ListItem value="">--Select One--</asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="LongDistance" runat="server" class="select ">
  <asp:ListItem value="2">$2 per mile</asp:ListItem>
  <asp:ListItem value="4">$4 per mile</asp:ListItem>
</asp:DropDownList>


        Dim StrSQL As String = ""
        Dim rs As OleDbDataReader
        Dim val As String = tripType.SelectedItem.Value
        If ((val = "one_way_to_airport") Or (val = "one_way_from_airport") Or (val = "round_trip_airport") Or (val = "one_way_no_airport") Or (val = "round_trip_no_airport")) Then
            StrSQL = "select r.fare, r.tip, r.total from Rates r "
            StrSQL += " Where r.city = @city "
            'Response.Write(StrSQL)
            'Response.End()
        ElseIf val = "hourly" Then
            StrSQL = "select distinct h.hourly, Switch([CarTypes] = 'Sedan', 55, [CarTypes] = 'Stretch (6 Passengers)', 75," & _
                 " [CarTypes] = 'Stretch (8 Passengers)', 90, [CarTypes] = 'Stretch (10 Passengers)', 95, " & _
                 " [CarTypes] = 'Stretch (12 Passengers)', 110 ,1=1, 10000)* h.hourly   as Fares, " & _
                 " Switch([CarTypes] = 'Sedan', 55, [CarTypes] = 'Stretch (6 Passengers)', 75," & _
                 " [CarTypes] = 'Stretch (8 Passengers)', 90, [CarTypes] = 'Stretch (10 Passengers)', 95, " & _
                 " [CarTypes] = 'Stretch (12 Passengers)', 110)* h.hourly*0.7 as tip, " & _
                 " Switch([CarTypes]  = 'Sedan', 55, [CarTypes] = 'Stretch (6 Passengers)', 75," & _
                 " [CarTypes] = 'Stretch (8 Passengers)', 90,[CarTypes] = 'Stretch (10 Passengers)', 95, " & _
                 " [CarTypes] = 'Stretch (12 Passengers)', 110, 1=1, 10000)*0.20*h.hourly as gratuity,  " & _
                 " fares+tip+gratuity as total from HourlyRates h " & _
                 " inner join carType c on h.hourly = c.hourly Where h.Hourly = @hourly"
            ' Response.Write(StrSQL)
            'Response.End()
        End If
        ' Initialize Database Connection
        Dim connStr As String = ConfigurationManager.ConnectionStrings("ALSConnectionString").ConnectionString
        Dim conn As New OleDbConnection(connStr)
        Dim cmd As New OleDbCommand(StrSQL, conn)

        'We use parametized query to prevent sql injection attack
        Dim p1 As New OleDbParameter("@city", lblPreviewfromCityState.Text)
        Dim p2 As New OleDbParameter("@hourly", HourlyCharter.SelectedValue)
        cmd.Parameters.Add(p1)
        cmd.Parameters.Add(p2)

        'Now open connection to the db
        conn.Open()

        'open recordset to receive db values
        rs = cmd.ExecuteReader()

        ' This acts like the (Not RecordSource.Eof) in ASP 3.0 to loop and retrieve records.
        While rs.Read()
            '    If rs("city") <> "" Then
            Dim tipValue As Decimal = rs("tip")
            Dim totValue = rs("total")
            '   Else
            '   End If
            Dim tp As String = [String].Format("{0:C}", tipValue)
            Dim tot As String = [String].Format("{0:C}", totValue)
            lblTip.Text = tp
            lblTotal.Text = tot

     End While

Questionserver did not recognize the value of http header soapaction c# .net Pin
Member 1032578924-Nov-14 2:30
Member 1032578924-Nov-14 2:30 
QuestionASP.NET C# Dynamically add my selected item from dropdown to below with div tags Pin
Member 1034105324-Nov-14 0:02
Member 1034105324-Nov-14 0:02 
AnswerRe: ASP.NET C# Dynamically add my selected item from dropdown to below with div tags Pin
2374126-Nov-14 18:39
2374126-Nov-14 18:39 
QuestionExcel like filter Grid using ASP.Net MVC Pin
indian14323-Nov-14 10:27
indian14323-Nov-14 10:27 
AnswerRe: Excel like filter Grid using ASP.Net MVC Pin
Anurag Gandhi30-Nov-14 22:47
professionalAnurag Gandhi30-Nov-14 22:47 
GeneralRe: Excel like filter Grid using ASP.Net MVC Pin
indian1434-Dec-14 11:17
indian1434-Dec-14 11:17 
GeneralRe: Excel like filter Grid using ASP.Net MVC Pin
Anurag Gandhi4-Dec-14 18:04
professionalAnurag Gandhi4-Dec-14 18:04 
QuestionMaintain scroll position Pin
BobbyStrain21-Nov-14 14:07
BobbyStrain21-Nov-14 14:07 
AnswerRe: Maintain scroll position Pin
jkirkerx25-Nov-14 12:52
professionaljkirkerx25-Nov-14 12:52 
GeneralRe: Maintain scroll position Pin
BobbyStrain26-Nov-14 17:03
BobbyStrain26-Nov-14 17:03 
GeneralRe: Maintain scroll position Pin
jkirkerx27-Nov-14 11:39
professionaljkirkerx27-Nov-14 11:39 
GeneralRe: Maintain scroll position Pin
BobbyStrain29-Nov-14 11:44
BobbyStrain29-Nov-14 11:44 
GeneralRe: Maintain scroll position Pin
jkirkerx29-Nov-14 12:13
professionaljkirkerx29-Nov-14 12:13 
GeneralRe: Maintain scroll position Pin
BobbyStrain30-Nov-14 14:38
BobbyStrain30-Nov-14 14:38 
GeneralRe: Maintain scroll position Pin
BobbyStrain8-Dec-14 12:19
BobbyStrain8-Dec-14 12:19 
GeneralRe: Maintain scroll position Pin
jkirkerx8-Dec-14 12:47
professionaljkirkerx8-Dec-14 12:47 
Questionconnection string Pin
dinusahu21-Nov-14 6:34
dinusahu21-Nov-14 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.