Имею следующий код в файле index.aspx.cs
namespace Namespace.Index
{
/// <summary>
/// Summary description for index.aspx.
/// </summary>
public class _Index : System.Web.UI.Page
{
//private DataSet topicsDS;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private SqlConnection sqlCon;
private SqlDataAdapter sqlCmd;
protected System.Web.UI.WebControls.DataList dls;
//private SqlCommand sqlCmd;
private void Page_Load(object sender, System.EventArgs e)
{
sqlCon=DBtools.makeConnection();
SqlDataAdapter sqlCmd = new SqlDataAdapter("SELECT " +
" * FROM Authors", sqlCon);
// Create and fill a DataSet.
DataSet ds = new DataSet();
DataGrid dg = new DataGrid();
sqlCmd.Fill(ds);
// Bind MyDataGrid to the DataSet. MyDataGrid is the ID for the
// DataGrid control in the HTML section.
DataView source = new DataView(ds.Tables[0]);
dg.DataSource = source ;
dg.DataBind();
}
//Дальше все, что обычно ставится студией 7 по умолчанию
И aspx-файл, который должен отобразить данные из таблицы
<%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="Namespace.Index._Index" debug="True"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Safed online</title>
<meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<ASP:DataGrid id="dg" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</form>
</body>
</HTML>
ConnectionString создается. Но Datagrid не выводится.
Что делаю не верно?
Здравствуйте, Larvef, Вы писали:
L>L><%@ Page language="c#" Codebehind="index.aspx.cs" AutoEventWireup="false" Inherits="Namespace.Index._Index" debug="True"%>
L><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
L><HTML>
L> <HEAD>
L> <title>Safed online</title>
L> <meta content="Microsoft Visual Studio 7.0" name="GENERATOR">
L> <meta content="C#" name="CODE_LANGUAGE">
L> <meta content="JavaScript" name="vs_defaultClientScript">
L> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
L> </HEAD>
L> <body MS_POSITIONING="GridLayout">
L> <form id="Form1" method="post" runat="server">
L> <ASP:DataGrid id="dg" runat="server"
AutoGenerateColumns="true"
L> Width="700"
L> BackColor="#ccccff"
L> BorderColor="black"
L> ShowFooter="false"
L> CellPadding=3
L> CellSpacing="0"
L> Font-Name="Verdana"
L> Font-Size="8pt"
L> HeaderStyle-BackColor="#aaaadd"
L> EnableViewState="false"
L> />
L> </form>
L> </body>
L></HTML>
L>
Попробуй добавить строчку, выделенную жирным шрифтом.
... << RSDN@Home 1.0 beta 6a >>