С праздником всех!
что я делаю не так
1) создал проект ASP.Net
2) размещаю sqlConnection1, устанавливаю ConnectionString=user id=sa;data source=vipr;persist security info=True;initial catalog=pubs;password=7777777
3)размещаю sqlDataAdapter1 и устанавливаю CommandText=select * from authors, в контекстном меню выполняю Generate Dataset
4) размещаю dataGrid1 в свойстве DataSet=dataSet11, DataMember=Table
5) ввожу
dataGrid1.DataSource=dataSet11;
dataGrid1.DataBind();
в private void Page_Load(object sender, System.EventArgs e)
Компилирую, выводится IE7 с пустым dataGrid, в таблице данные есть, а на экране нет.
Далее указываю полный код проекта:
<%@ Page Language="c#" Debug="true" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication3.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
<form runat="server">
<ASP:DataGrid id="dataGrid1" runat="server" width="738px" datasource="<%# dataSet11 %>" datamember="Table"></ASP:DataGrid>
</form>
</body>
</html>
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
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 WebApplication3
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected WebApplication3.DataSet1 dataSet11;
protected System.Web.UI.WebControls.DataGrid dataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
dataGrid1.DataSource=dataSet11;
dataGrid1.DataBind();
}
#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.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.dataSet11 = new WebApplication3.DataSet1();
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "user id=sa;data source=vipr;persist security info=True;initial ca" +
"talog=pubs;password=7777777";
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "select * from authors";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// dataSet11
//
this.dataSet11.DataSetName = "DataSet1";
this.dataSet11.Locale = new System.Globalization.CultureInfo("ru-RU");
this.dataSet11.Namespace = "
http://www.changeme.now/DataSet1.xsd";
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
}
#endregion
}
}