Wrox Programmer Forums
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 August 9th, 2006, 10:39 PM
Authorized User
Join Date: Jul 2005
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bind result set to Html Div Controls

Hello and thanks for taking a second. I am simply trying to query the Northwind database. The user will give the order number and the name of the employee who took the order and the order date will be displayed in separate html div tags. The page builds but my events do not seem to be running. Any Advice? Below is my .aspx and code behind. Thanks- Jason

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="orderinfoweb.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
        <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" Content="C#">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <body MS_POSITIONING="GridLayout">
        <form id="Form1" method="post" runat="server">
            <b>Put the Order ID in to Find out who took the order and on what date the order
                was placed:</b>&nbsp; <INPUT type="text" id="orderID" runat="server"><br>
            <input type="submit" value="search" id="txtsearch" OnShowInfo="ShowInfo" runat="server"><br>
            Order Date<div id="DivOrderDate" runat="server"></div>
            Employee who took order was
            <div id="DivEmployee" runat="server"></div>
            <div id="DivError" runat="server"></div>

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace orderinfoweb
    /// <summary>
    /// Summary description for WebForm1.
    /// </summary>
    public class WebForm1 : System.Web.UI.Page
        protected System.Web.UI.HtmlControls.HtmlGenericControl DivEmployee;
        protected System.Web.UI.HtmlControls.HtmlInputButton txtsearch;
        protected System.Web.UI.HtmlControls.HtmlGenericControl DivOrderDate;
        protected System.Web.UI.HtmlControls.HtmlGenericControl DivError;
        protected System.Web.UI.HtmlControls.HtmlInputText orderID;
        protected System.Web.UI.HtmlControls.HtmlInputText OrderId ;

        private void Page_Load(object sender, System.EventArgs e)
            // Put user code to initialize the page here

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
            // CODEGEN: This call is required by the ASP.NET Web Form Designer.

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
            this.Load += new System.EventHandler(this.Page_Load);

        private void ShowInfo(Object sender,EventArgs e)
            //Declare connection and stored proc to get info
            SqlConnection myConnection = new SqlConnection();
            myConnection.ConnectionString="Data Source=Jason;" + "Initial Catalog=Pubs; User ID=sa";
            SqlCommand sqlCom = new SqlCommand("usp_retrieve_Order_info");

            sqlCom.CommandType = CommandType.StoredProcedure;

            //Add parameters and setting values

            sqlCom.Parameters["@OrderID"].Value =OrderId.Value;

            //declare dataAdapter to fill Dataset
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(sqlCom);

            //Fill dataSet DS with results set and name the filled table "tblResultSet"
            da.Fill(ds, "tblResultSet");

            if(ds.Tables["tblResultSet"].Rows.Count > 0)
                //Fill Divs with with information from Dataset

                DivOrderDate.InnerText = ds.Tables["tblResultSet"].Rows[0]["Employee"].ToString();
                DivEmployee.InnerText=ds.Tables["tblResultSet"]. Rows[0]["OrderDate"].ToString();



                DivError.InnerText="Order was not found";



Old August 10th, 2006, 07:35 AM
Wrox Author
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

Are you 100 percent sure that data is being returned by your query during program execution?

"The one language all programmers understand is profanity."

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Bind the HTML-Textbox Value in Detailsview kcsathish ASP.NET 2.0 Basics 1 July 30th, 2008 04:34 AM
CMS: Bind Nav Data to Treeview/Menu controls bullwinkle BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 October 25th, 2007 02:33 PM
How to bind Gridview with controls hyder_master .NET Framework 2.0 0 October 5th, 2007 05:01 AM
Data Bind Template Controls in Gridview wirerider ASP.NET 2.0 Basics 5 February 4th, 2007 07:20 AM
How to bind colors to controls in an formview leverell ASP.NET 2.0 Professional 0 May 31st, 2006 02:00 AM

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