p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 9th, 2006, 11:39 PM
Authorized User
Points: 232, Level: 4
Points: 232, Level: 4 Points: 232, Level: 4 Points: 232, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2005
Location: , , .
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" >
<HTML>
    <HEAD>
        <title>WebForm1</title>
        <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">
    </HEAD>
    <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>
            <br>
            <input type="submit" value="search" id="txtsearch" OnShowInfo="ShowInfo" runat="server"><br>
            <br>
            Order Date<div id="DivOrderDate" runat="server"></div>
            <br>
            Employee who took order was
            <div id="DivEmployee" runat="server"></div>
            <br>
            <br>
            <div id="DivError" runat="server"></div>
        </form>
    </body>
</HTML>

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.
            //
            InitializeComponent();
            base.OnInit(e);
        }

        /// <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);

        }
        #endregion
        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.Connection=myConnection;
            sqlCom.CommandType = CommandType.StoredProcedure;

            //Add parameters and setting values

            sqlCom.Parameters.Add("@OrderId",SqlDbType.Int);
            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();

            }

            else

            {
                DivError.InnerText="Order was not found";



            }






        }
    }
}








Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old August 10th, 2006, 08:35 AM
Wrox Author
Points: 12,827, Level: 49
Points: 12,827, Level: 49 Points: 12,827, Level: 49 Points: 12,827, Level: 49
Activity: 15%
Activity: 15% Activity: 15% Activity: 15%
 
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,029
Thanks: 1
Thanked 42 Times in 42 Posts
Send a message via AIM to dparsons
Default

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

"The one language all programmers understand is profanity."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 05: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 03:33 PM
How to bind Gridview with controls hyder_master .NET Framework 2.0 0 October 5th, 2007 06: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 03:00 AM



All times are GMT -4. The time now is 01:13 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc