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.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection conn = new
SqlConnection(" server=localhos t;uid=sa;pwd=;d atabase=northwi nd");
SqlCommand cmd = new SqlCommand("Emp loyeesList", conn);
cmd.CommandType = CommandType.Sto redProcedure;
conn.Open();
DataGrid1.DataS ource = cmd.ExecuteRead er(Commandbehav iour.CloseConne ction);
DataGrid1.DataB ind();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
}
then:
<%@ Page language="c#" Codebehind="Web form1.aspx.cs" AutoEventWireup ="false"
Inherits="dbtes t.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio 7.0">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.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 1248
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.c om> wrote in message
news:ej******** *****@TK2MSFTNG P14.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.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection conn = new SqlConnection(" server=localhos t;uid=sa;pwd=;d atabase=northwi nd");
SqlCommand cmd = new SqlCommand("Emp loyeesList", conn);
cmd.CommandType = CommandType.Sto redProcedure;
conn.Open();
DataGrid1.DataS ource =
cmd.ExecuteRead er(Commandbehav iour.CloseConne ction); DataGrid1.DataB ind();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
} then:
<%@ Page language="c#" Codebehind="Web form1.aspx.cs"
AutoEventWireup ="false" Inherits="dbtes t.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1 </title> <meta name="GENERATOR " Content="Micros oft Visual Studio 7.0"> <meta name="CODE_LANG UAGE" Content="C#"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.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 "CommandBehavio r" is mispelled "Commandbehavio ur". 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.c om> wrote in message
news:ej******** *****@TK2MSFTNG P14.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.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection conn = new SqlConnection(" server=localhos t;uid=sa;pwd=;d atabase=northwi nd");
SqlCommand cmd = new SqlCommand("Emp loyeesList", conn);
cmd.CommandType = CommandType.Sto redProcedure;
conn.Open();
DataGrid1.DataS ource =
cmd.ExecuteRead er(Commandbehav iour.CloseConne ction); DataGrid1.DataB ind();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
} then:
<%@ Page language="c#" Codebehind="Web form1.aspx.cs"
AutoEventWireup ="false" Inherits="dbtes t.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1 </title> <meta name="GENERATOR " Content="Micros oft Visual Studio 7.0"> <meta name="CODE_LANG UAGE" Content="C#"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.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*******@hotm ail.com> wrote in message
news:ej******** ******@TK2MSFTN GP14.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.c om> wrote in message news:ej******** *****@TK2MSFTNG P14.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.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection conn = new SqlConnection(" server=localhos t;uid=sa;pwd=;d atabase=northwi nd");
SqlCommand cmd = new SqlCommand("Emp loyeesList", conn);
cmd.CommandType = CommandType.Sto redProcedure;
conn.Open();
DataGrid1.DataS ource = cmd.ExecuteRead er(Commandbehav iour.CloseConne ction); DataGrid1.DataB ind();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
} then:
<%@ Page language="c#" Codebehind="Web form1.aspx.cs"
AutoEventWireup ="false" Inherits="dbtes t.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1 </title> <meta name="GENERATOR " Content="Micros oft Visual Studio 7.0"> <meta name="CODE_LANG UAGE" Content="C#"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.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*******@hotm ail.com> wrote in message
news:ej******** ******@TK2MSFTN GP14.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.c om> wrote in message news:ej******** *****@TK2MSFTNG P14.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.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection conn = new SqlConnection(" server=localhos t;uid=sa;pwd=;d atabase=northwi nd");
SqlCommand cmd = new SqlCommand("Emp loyeesList", conn);
cmd.CommandType = CommandType.Sto redProcedure;
conn.Open();
DataGrid1.DataS ource = cmd.ExecuteRead er(Commandbehav iour.CloseConne ction); DataGrid1.DataB ind();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
} then:
<%@ Page language="c#" Codebehind="Web form1.aspx.cs"
AutoEventWireup ="false" Inherits="dbtes t.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1 </title> <meta name="GENERATOR " Content="Micros oft Visual Studio 7.0"> <meta name="CODE_LANG UAGE" Content="C#"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.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.sol ien.nospam.com> wrote in message
news:5c******** ************@co mcast.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 "CommandBehavio r" is mispelled "Commandbehavio ur". 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.c om> wrote in message news:ej******** *****@TK2MSFTNG P14.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.Configur ation;
using System.Data;
using System.Data.Sql Client;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
namespace dbtest
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Data Grid DataGrid1;
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection conn = new SqlConnection(" server=localhos t;uid=sa;pwd=;d atabase=northwi nd");
SqlCommand cmd = new SqlCommand("Emp loyeesList", conn);
cmd.CommandType = CommandType.Sto redProcedure;
conn.Open();
DataGrid1.DataS ource = cmd.ExecuteRead er(Commandbehav iour.CloseConne ction); DataGrid1.DataB ind();
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
}
} then:
<%@ Page language="c#" Codebehind="Web form1.aspx.cs"
AutoEventWireup ="false" Inherits="dbtes t.WebForm1" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>WebForm1 </title> <meta name="GENERATOR " Content="Micros oft Visual Studio 7.0"> <meta name="CODE_LANG UAGE" Content="C#"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.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 the grid population event and the other is to populate the dropdownlist
I'll start with the method that binds the dropdownlist. As mentioned it is object based and also works fine everywhere but in a template column. I have put in some comments...
|
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 populate the second dropdown, as its not
bale to find the specified control, even though the dropdownlist with the
specified name exists in the datagrid.
my .aspx page code goes like this
|
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 databases, the data is
ordered alphabetically but is grouped by database.
Here is an example of what is happening to the data in the datgrid with
the code that I have now.
DB1 Apple
DB1 Bird
DB1 Cake
|
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 let me. I just
cant find the control in the controlcollection for the cell. Is it because it
hasnt rendered yet? (very annoying as i have set the edititem to the index,
done my databound etc.) why doesnt it recognise the textbox? so:
...
|
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 will be used to populate information coming from a Webservice. (No
datasets - No datareaders).
So, I do not know see how to use the "datasource".
| |
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 my rows back
to their defaults. I populate the datagrid, resize it accordingly and
it works fine...just when I click the headers is when it messes up. It
would be fine if I could run my autosizing again after the sorting is
done since there...
|
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 CartTable programmatically with rows from a database binded
datagrid..
i cant figure out what is wroooong! hehe thanks for helping
here is my code:
TABLE CODE (in the page_load):
If Session("shop_cart") Is Nothing Then
|
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 again, the datagrid is not there to
see. I'm running the same code to populate it. What is happening? Any
suggestions?
thanks,
Will
|
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 reflect the
values they anticipate committing to see hypothetical totals of
columns from a set of records. These records are displaying properly
on my DataGrid but I'm not sure how to get Crystal Reports 10 to use
as its datasource the dataset...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |