一个怪问题?只有能帮我解决,分数不是“?”
我在调试.NET网页的时候遇到一个怪问题,调试都能通过!可浏览页面上却是一个大空白!
这不是一个页面,所有的只要涉及到数据绑定的网页都是这样,也没有什么提示信息,难道问题出在我的浏览器,我装的WIN2K,但是我的IE我已经升级到6.0,真TMD郁闷,在网上发了几天的贴子都没有人能帮我真正解决!有没有人帮在下一下,分数不是“?“
问题点数:20、回复次数:7Top
1 楼LaoDai_Net(『老代』)回复于 2005-06-04 12:11:23 得分 0
你把运行后的html代码贴出来看看Top
2 楼godblessyU(痛并快乐着!)回复于 2005-06-04 12:11:44 得分 0
你把窗体中控件的style属性删除,如下:
<span id="Label1" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 248px">Label</span>
改为
<span id="Label1">Label</span>
Top
3 楼yhan1699(子吟)回复于 2005-06-04 12:51:36 得分 0
<%@ import namespace="system.data.sqlclient"%>
<%@ import namespace="system.data"%>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="index.aspx.vb" Inherits="Web.index"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>index</title>
<script runat="server">
dim conn1 as new sqlclient.sqlconnection()
dim comm1 as new sqlclient.sqlcommand()
dim ad1 as new sqlclient.sqldataadapter()
dim ds1 as new dataset()
sub page_load(byval sender as object,byval e as eventargs)
if not page.ispostback then
conn1.connectionstring="server=localhost;database=master;user id=sa;password="
conn1.open()
comm1.connection=conn1
comm1.commandtext="select*from Products"
ad1.selectcommand=comm1
ad1.fill(ds1,"Products")
datagrid1.datasource=ds1.tables("Products")
datagrid1.databind()
end if
end sub
</script>
<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/ie3-2nav3-0">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<p align="center"></p>
<p align="center">
</p>
<FONT face="宋体">
<P align="center"> </P>
</FONT>
</form>
<P align="center">
<asp:DataGrid ID="datagrid1" Runat="server" Width="721px" BorderWidth="2px" Visible="True"
HorizontalAlign="Center" AllowPaging="True" PageSize="10" PagerStyle-Mode="NumericPages" AutoGenerateColumns="False">
<Itemstyle Font-Bold="True" BorderStyle="Solid" BorderColor="#66cc33" BackColor="#ffff00"></Itemstyle>
<HeaderStyle Font-Bold="true" ForeColor="blue" BackColor="#ffc080"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Productid" HeaderText="ID编号"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductName" HeaderText="产品名称"></asp:BoundColumn>
<asp:BoundColumn DataField="UnitPrice" HeaderText="产品单价"></asp:BoundColumn>
</Columns>
</asp:DataGrid></P>
</body>
</HTML>
首先声明数据库里有products表,并且表里有数据Top
4 楼itflying(it学习者 )回复于 2005-06-04 13:01:13 得分 0
建议你使用这个连接代码,试试,其他的看不出问题!!!
dim conn as new sqlconnection("server=localhost;database=master;user id=sa;password=")
sql="select*from Products"
dim adapter1 as new sqldataadapter(sql,conn)Top
5 楼LaoDai_Net(『老代』)回复于 2005-06-04 13:12:40 得分 20
DataGrid 要放在 <form runat=server></form> 之间
还有就是 你既然使用codebehind 怎么又在aspx文件中写上代码了啊
SQL语句 select * from Products 加上空格
我改了一下,你拷贝看看能不能运行
<%@ import namespace="system.data.sqlclient"%>
<%@ import namespace="system.data"%>
<%@ Page Language="vb" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>index</title>
<script runat="server">
dim conn1 as new sqlclient.sqlconnection()
dim comm1 as new sqlclient.sqlcommand()
dim ad1 as new sqlclient.sqldataadapter()
dim ds1 as new dataset()
sub page_load(byval sender as object,byval e as eventargs)
if not page.ispostback then
conn1.connectionstring="server=(local);database=你的数据库;user id=sa;password=密码"
conn1.open()
comm1.connection=conn1
comm1.commandtext="select * from Products"
ad1.selectcommand=comm1
ad1.fill(ds1,"Products")
datagrid1.datasource=ds1.tables("Products")
datagrid1.databind()
conn1.Close()
end if
end sub
</script>
<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/ie3-2nav3-0">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<p align="center">test</p>
<p align="center">
</p>
<FONT face="宋体">
<P align="center"> </P>
</FONT>
<P align="center">
<asp:DataGrid ID="datagrid1" Runat="server" Width="721px" BorderWidth="2px" Visible="True"
HorizontalAlign="Center" AllowPaging="True" PageSize="10" PagerStyle-Mode="NumericPages" AutoGenerateColumns="False">
<Itemstyle Font-Bold="True" BorderStyle="Solid" BorderColor="#66cc33" BackColor="#ffff00"></Itemstyle>
<HeaderStyle Font-Bold="true" ForeColor="blue" BackColor="#ffc080"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="Productid" HeaderText="ID编号"></asp:BoundColumn>
<asp:BoundColumn DataField="ProductName" HeaderText="产品名称"></asp:BoundColumn>
<asp:BoundColumn DataField="UnitPrice" HeaderText="产品单价"></asp:BoundColumn>
</Columns>
</asp:DataGrid></P>
</form>
</body>
</HTML>
Top
6 楼LaoDai_Net(『老代』)回复于 2005-06-04 13:16:04 得分 0
我在本机运行正常
还有什么问题,请留言Top
7 楼yhan1699(子吟)回复于 2005-06-04 14:36:01 得分 0
非常感谢LaoDai_Net,非常感谢!
你找这个贴子,里面去说句话,标题为:在线请教DataGrid 问题!
我把这个贴子里的分数也给你,真是一语惊醒梦中人!你使我又进步了不少
很想和你交个朋友,惹不嫌弃请加我QQ:185663280Top




