Wrox Programmer Forums
|
BOOK: Professional ASP.NET 1.0, Special Edition/1.1
This is the forum to discuss the Wrox book Professional ASP.NET 1.1 by Alex Homer, Dave Sussman, Rob Howard, Brian Francis, Karli Watson, Richard Anderson; ISBN: 9780764558900
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET 1.0, Special Edition/1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 2nd, 2004, 03:45 AM
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default first example chapter 1, Professional ASP.NET 1.1

It is me or could no one get the drop down list with the datagrid to work, upon inspecting the code it would appear that in the How it Works Section they reference a DSN in a web.config file? i've not seen anywhere else telling me to set up DSN or use them in the code example...

bad example me thinks...

anyone else seen this?



 
Old September 23rd, 2004, 01:55 PM
Registered User
 
Join Date: Sep 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Give you the full sample:

Samplepage.aspx:

<%@ Page Language="vb" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    Sub Page_Load(Sender As Object, E As EventArgs)
      If Not Page.IsPostBack Then
          state.Items.Add("CA")
          state.Items.Add("IN")
          state.Items.Add("KS")
          state.Items.Add("MD")
          state.Items.Add("MI")
          state.Items.Add("OR")
          state.Items.Add("TN")
          state.Items.Add("UT")
      End If

    End Sub

    Sub ShowAuthors(Sender As Object, E As EventArgs)

      Dim con As New SqlConnection(ConfigurationSettings.AppSettings("D snPubs"))
      Dim cmd As SqlCommand
      Dim qry As String

      con.Open()

      qry = "select * from authors where state='" & state.SelectedItem.Text & "'"
      cmd = New SqlCommand(qry, con)

      DataGrid1.DataSource = cmd.ExecuteReader()
      DataGrid1.DataBind()

      con.Close()

    End Sub

</script>
<html>
<head>
</head>
<body>
    <pre>


    <form runat="server">
        State:<asp:DropDownList id="state" runat="server"></asp:DropDownList>
        <asp:Button id="Button1" onclick="ShowAuthors" runat="server" Text="Show Authors"></asp:Button>
        <p>
            <asp:DataGrid id="DataGrid1" runat="server" AllowSorting="True" CellPadding="4" BackColor="White" BorderColor="#3366CC" BorderWidth="1px" BorderStyle="None">
                <FooterStyle forecolor="#003399" backcolor="#99CCCC"></FooterStyle>
                <HeaderStyle font-bold="True" forecolor="#CCCCFF" backcolor="#003399"></HeaderStyle>
                <PagerStyle horizontalalign="Left" forecolor="#003399" backcolor="#99CCCC" mode="NumericPages"></PagerStyle>
                <SelectedItemStyle font-bold="True" forecolor="#CCFF99" backcolor="#009999"></SelectedItemStyle>
                <ItemStyle forecolor="#003399" backcolor="White"></ItemStyle>
            </asp:DataGrid>
        </p>
    </form>
    </pre>
</body>
</html>









Similar Threads
Thread Thread Starter Forum Replies Last Post
Professional ASP 3.0, chapter 6 ne0 All Other Wrox Books 5 July 23rd, 2003 08:48 AM
Professional ASP.NET davem1958 All Other Wrox Books 0 June 11th, 2003 10:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.