我试过了,无论是VB还是C#效果都是一样的。
请再看下面的代码,我设了居中对齐,可结果还是。
<%@ import namespace="System.Data.OleDb" %>
<%@ import namespace="system.data" %>
<%@ Page Language="vb" AutoEventWireup="true" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm7</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language=vb runat=server >
Dim conn As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\\Program Files\\Microsoft Office\\OFFICE\\SAMPLES\\Northwind.mdb")
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If (Not IsPostBack) Then
DataGridBind()
End If
End Sub
Sub DataGridBind()
Dim strSql As String
strSql = "select * from 产品"
Dim ds As New DataSet
Dim myAdapter As New OleDbDataAdapter(strSql, conn)
myAdapter.Fill(ds, "ds")
Dim dv As DataView = ds.Tables(0).DefaultView
DataGrid1.DataSource = dv
DataGrid1.DataBind()
conn.Close()
End Sub
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体">
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 160px"
runat="server" Width="632px" Height="128px" AllowPaging="True" PageSize=3>
<PagerStyle Width="100%" HorizontalAlign="Center" Wrap="False"
Mode="NumericPages" ></PagerStyle>
</asp:DataGrid></FONT>
</form>
</body>
</HTML>
[此贴子已经被作者于2006-10-13 10:01:59编辑过]