程序没报错的话就没错.
?蔾錵輐落溶溶钥,柳絮筂鎕淡淡風?。
//web.Config
<configurations>
<connectionStrings>
<add name="sqlCon" ConnectionString="data source=localhost; pwd=sa; uid=sa;database=student" Provider="System.Data.SqlClient">
</add>
</connectionStrings>
</Configurations>
//.aspx
<html>
<head>
</head>
<body>
<form runat="server">
<asp:DataGrid id="DG1" runat="server" HeaderStyle-BackColor="#aaaadd"></asp:DataGrid>
</form>
</body>
</html>
//.aspx.cs
using System.Data.Configuration;
using System.Data.SqlClient;
protected void Page_Load(object sender,EventArgs e)
{
ConnectionStringSettings sql=ConfigurationManager.ConnectionStrings["sqlCon"];
string strText="select * from class";
SqlConnection strCon=new SqlConnection(sql.ConnectionString);
SqlDataAdapter da=new SqlDataAdapter(strText,strCon);
DataSet ds=new DataSet();
da.Fill(ds,"class");
DG1.DataSource=ds.Tables["class"].DefaultView;
DG1.DataBind();
}