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 May 23rd, 2005, 01:41 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Trouble displaying Data Grid control

Hi,
I have been trying to display some data in a datagrid control .All the other controls in the form are displayed but not DataGrid Control and also the Page load event is not firing.When I run the following code,I get the button and textbox displayed and nothing else.


<%@ import Namespace="System.Data.SqlClient" %>
<%@import Namespace="System.Data"%>
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" AutoEventWireup="false" Inherits="aspdotnet.WebForm2"%>

<script Runat="server">
void Page_Load(Object sender,EventArgs e)
{
Response.Write("In");
SqlConnection myconn =new SqlConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=PRIYA;Data Source=ROC06650");
SqlDataAdapter mycomm=new SqlDataAdapter("select * from baby",myconn);
DataSet ds=new DataSet();
mycomm.Fill(ds);
DataGrid1.DataSource=ds;
DataGrid1.DataBind();
Response.Write("connected");
}
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >

<HTML>
    <HEAD>
        <title>WebForm2</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">
            <asp:DataGrid ID="DataGrid1"
                        Runat="server"></asp:DataGrid>
            <asp:Button ID="button1"
                        Runat="server"></asp:Button>
            <asp:TextBox ID="text1"
                        Runat="server"></asp:TextBox>
        </form>
    </body>
</HTML>
Any help would be appreciated.Thanks.

 
Old May 23rd, 2005, 06:00 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You've put a Page_Load method in inline code. When you do this, you need to make sure the @Page directive AutoEventWireup attribute is "True" otherwise the ASP.NET runtime will ignore the method in inline code.

-Peter
 
Old May 24th, 2005, 01:33 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Peter.It works but would you mind telling me what is inline code?

 
Old May 24th, 2005, 03:52 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What you have in your initial post in inline code. The server code appears in the markup file in a server script block, versus in a code-behind file.

-Peter
 
Old May 25th, 2005, 07:59 AM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thans very much






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem Displaying Data Using Repeater Control cyberstore05 ASP.NET 2.0 Professional 0 January 5th, 2008 01:45 PM
Error in displaying data grid lamort ASP.NET 2.0 Basics 2 December 1st, 2006 08:55 PM
trouble displaying data from array Arsi C# 1 October 22nd, 2004 04:13 PM





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