Hello
Im trying to do a simple page with data from my local sql server, and page
just shows up blank...... I created a stored procedure with SELECT * FROM
Employees......
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new
SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(Commandbehaviour.CloseConnection );
DataGrid1.DataBind();
// 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
}
}
then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs" AutoEventWireup="false"
Inherits="dbtest.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<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" />
</form>
</body>
</HTML> 5 1228
Hi,
First, are you sure the stored procedure returns results?
Second, it might be the case when aspx pages don't get processed (see http://support.microsoft.com/?kbid=325093). try inserting a Label on the
page and setting its Text property from the code-behind class to see if it's
rendered correctly.
Hope this helps
Martin
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:ej*************@TK2MSFTNGP14.phx.gbl... Hello
Im trying to do a simple page with data from my local sql server, and page just shows up blank...... I created a stored procedure with SELECT * FROM Employees......
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource =
cmd.ExecuteReader(Commandbehaviour.CloseConnection ); DataGrid1.DataBind();
// 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
}
} then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs"
AutoEventWireup="false" Inherits="dbtest.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <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" />
</form> </body> </HTML>
Have you compiled your code?
I checked your program and if its written exactly as it is in here, it won't
compile because "CommandBehavior" is mispelled "Commandbehaviour". Also
remember that case is important in C#.
When I corrected this and compiled the application, the DataGrid showed all
of the records.
--
Ben Lucas
Lead Developer
Solien Technology, Inc. www.solien.com
"Lasse Edsvik" <la***@nospam.com> wrote in message
news:ej*************@TK2MSFTNGP14.phx.gbl... Hello
Im trying to do a simple page with data from my local sql server, and page just shows up blank...... I created a stored procedure with SELECT * FROM Employees......
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource =
cmd.ExecuteReader(Commandbehaviour.CloseConnection ); DataGrid1.DataBind();
// 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
}
} then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs"
AutoEventWireup="false" Inherits="dbtest.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <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" />
</form> </body> </HTML>
Martin,
It returns 9, im very sure........
something fishy is going on....... i put in Response.Write("test") and
still the page shows up blank......
i put in "test" in the html-part of the page and it shows....... why isnt
Page_Load event triggered?
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:ej**************@TK2MSFTNGP14.phx.gbl... Hi,
First, are you sure the stored procedure returns results?
Second, it might be the case when aspx pages don't get processed (see http://support.microsoft.com/?kbid=325093). try inserting a Label on the page and setting its Text property from the code-behind class to see if
it's rendered correctly.
Hope this helps Martin "Lasse Edsvik" <la***@nospam.com> wrote in message news:ej*************@TK2MSFTNGP14.phx.gbl... Hello
Im trying to do a simple page with data from my local sql server, and
page just shows up blank...... I created a stored procedure with SELECT *
FROM Employees......
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(Commandbehaviour.CloseConnection ); DataGrid1.DataBind();
// 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
}
} then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs"
AutoEventWireup="false" Inherits="dbtest.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <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" />
</form> </body> </HTML>
Martin,
and...... there is no serverside code in "view source"....
i've done some tests with asp.net and they have been executed, not sure what
went wrong in this case
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:ej**************@TK2MSFTNGP14.phx.gbl... Hi,
First, are you sure the stored procedure returns results?
Second, it might be the case when aspx pages don't get processed (see http://support.microsoft.com/?kbid=325093). try inserting a Label on the page and setting its Text property from the code-behind class to see if
it's rendered correctly.
Hope this helps Martin "Lasse Edsvik" <la***@nospam.com> wrote in message news:ej*************@TK2MSFTNGP14.phx.gbl... Hello
Im trying to do a simple page with data from my local sql server, and
page just shows up blank...... I created a stored procedure with SELECT *
FROM Employees......
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(Commandbehaviour.CloseConnection ); DataGrid1.DataBind();
// 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
}
} then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs"
AutoEventWireup="false" Inherits="dbtest.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <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" />
</form> </body> </HTML>
Ben,
thx :D
second case sensitive thing ive done today........
thanks again :)
/Lasse
"Ben Lucas" <be*@nospam.solien.nospam.com> wrote in message
news:5c********************@comcast.com... Have you compiled your code?
I checked your program and if its written exactly as it is in here, it
won't compile because "CommandBehavior" is mispelled "Commandbehaviour". Also remember that case is important in C#.
When I corrected this and compiled the application, the DataGrid showed
all of the records.
-- Ben Lucas Lead Developer Solien Technology, Inc. www.solien.com
"Lasse Edsvik" <la***@nospam.com> wrote in message news:ej*************@TK2MSFTNGP14.phx.gbl... Hello
Im trying to do a simple page with data from my local sql server, and
page just shows up blank...... I created a stored procedure with SELECT *
FROM Employees......
whats wrong?
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=;databa se=northwind");
SqlCommand cmd = new SqlCommand("EmployeesList", conn);
cmd.CommandType = CommandType.StoredProcedure;
conn.Open();
DataGrid1.DataSource = cmd.ExecuteReader(Commandbehaviour.CloseConnection ); DataGrid1.DataBind();
// 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
}
} then:
<%@ Page language="c#" Codebehind="Webform1.aspx.cs"
AutoEventWireup="false" Inherits="dbtest.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1</title> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0"> <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" />
</form> </body> </HTML>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Harold |
last post by:
Hi all, having a little difficulty binding up a dropdownlist control in a datagrid column. I know I must be missing something
Here are 2 methods. One is the DataGrid's ItemDataBound event to catch...
|
by: Shiju Poyilil |
last post by:
Hello,
I have a datagrid with only one row and its having 2 dropdownlists, I need
to populate the secodn dropdownlist on the basis of the selection in the
first dropdown. but I am not able to...
|
by: crjunk |
last post by:
I have 4 different databases that I'm having to pull data from in order
to populate a datagrid. I am able to do this, but my problem is that
because I'm pulling the data from 4 different...
|
by: louise raisbeck |
last post by:
Hi, I have been on this for hours and just cannot work it out.
I have a datagrid. I set the edititem index to a row to edit, that works.
However if i want to put a value into this textbox it wont...
|
by: Brett Sinclair |
last post by:
Hello everybody
I'm still on the learning curve here...and from what I read, I created
inherited datagrid class so I could have icons, combobox...etc in the
columns of my datagrid.
The grid...
|
by: skOOb33 |
last post by:
I successfully autosized the columns and rows on my Datagrid, and am
now facing another issue. Having the sorting ability by clicking the
column headers is key, but when I do that, it resizes all...
|
by: ismaelf |
last post by:
i have a textbox in a template column in a datagrid, it displays the
initial value of the row, but when i change it remains with the
original value (it doesnt get the new value..)
i fill the...
|
by: wk6pack |
last post by:
Hi,
I have a datagrid that is populated from a query in SQL Server. The first
time I run the form, it appears, I make changes or view it and it is fine.
When I close the form and open it up...
|
by: Brock |
last post by:
I am trying to populate a Crystal Report from data in my DataGrid. The
reason for this is that I want the user to be able to change values
without updating the database, but still have their report...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |