| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1252 人关注过本帖
标题:[求助]请问这个DataGrid怎么不显示?
只看楼主 加入收藏
gaoqiang1987
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-9-23
收藏
 问题点数:0 回复次数:18 
[求助]请问这个DataGrid怎么不显示?

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="insertrecord.aspx.vb" Inherits="insertrecord" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="system.data.oledb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="vbscript" type="text/vbscript" runat ="server">

Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
Dim myconnection As OleDbConnection
Dim dataadaper As OleDbDataAdapter
Dim myset As DataSet
myconnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & "h:\asp.net\information.mdb")
dataadaper = New OleDbDataAdapter("select * from information", myconnection)
myconnection.Open()
myset = New DataSet
dataadaper.Fill(myset)
information.DataSource = myset
information.DataBind()
End Sub
Sub information_pageindexchanged(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
information.CurrentPageIndex = e.NewPageIndex
DataBind()
End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页</title>
</head>

<body bgcolor="#990000" style="text-align: center">

<form id="form1" runat="server">
<span style="font-weight: bold; font-size: x-large; color: #ffcc00">欢迎光临我的留言簿<br />
<asp:DataGrid runat="server"
CellPadding="3"
CellSpacing="0"
Font-Size="10pt"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"
ID="information" AllowPaging="true" PageSize="3" ShowHeader="true" OnPageIndexChanged="information_pageindexchanged"/>

&nbsp;</span>
</form>

</body>
</html>

搜索更多相关主题的帖子: DataGrid 
2007-09-24 12:33
垃圾的沉默
Rank: 1
等 级:新手上路
威 望:2
帖 子:511
专家分:0
注 册:2007-6-25
收藏
得分:0 
<form id="form1" runat="server">
<span style="font-weight: bold; font-size: x-large; color: #ffcc00">欢迎光临我的留言簿<br />
<asp:DataGrid runat="server"
CellPadding="3"
CellSpacing="0"
Font-Size="10pt"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"
ID="information" AllowPaging="true" PageSize="3" ShowHeader="true" OnPageIndexChanged="information_pageindexchanged">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem,"字段")%>">

</td>
</tr>
</table>
</ItemTemplate>
</asp:DataGrid>
&nbsp;</span>
</form>

人们笑我太疯癫...我笑人们太正经
2007-09-24 12:41
gaoqiang1987
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-9-23
收藏
得分:0 
谢谢了,可它提示这条语句&lt;%# DataBinder.Eval(Container.DataItem,"字段")%&gt;"&gt;:说不支持代码块是什么意思?该怎样改进呢?
2007-09-24 13:16
垃圾的沉默
Rank: 1
等 级:新手上路
威 望:2
帖 子:511
专家分:0
注 册:2007-6-25
收藏
得分:0 
后台代码
OleDbConnection cnn;
OleDbDataAdapter cmd;
DataSet dt = new DataSet();
string strcnn, sql;
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("EDNdata/EDNdatabase.mdb");
cnn = new OleDbConnection(strcnn);
cnn.Open();
sql = "select top 16 * from Rmbq where Class=5 order by id desc";
cmd = new OleDbDataAdapter(sql, cnn);
cmd.Fill(dt);
DataListD.DataSource = dt;
DataListD.DataBind();
cnn.Close();
页面
<form runat="server>
<div style="overflow:hidden;height:24px;line-height:24px;font-size:13px" id="gdC0">
<asp:DataList ID="DataListC" runat="server" RepeatColumns="3">
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<a class="countD" href="<%# DataBinder.Eval(Container.DataItem,"url")%>" target="_blank">
&nbsp; &nbsp;<%# DataBinder.Eval(Container.DataItem,"Title") %></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</fotm>
DataList控件不支持分页的,想要分页还要手写代码

人们笑我太疯癫...我笑人们太正经
2007-09-24 13:25
gaoqiang1987
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-9-23
收藏
得分:0 
DataList控件不支持分页,DataGrid控件用做分页显示更合适吧,你这个程序里面还有"&lt;%# DataBinder.Eval(Container.DataItem,"url")%&gt;" 它照样会提示"不支持代码块".所以我就想问一下针对DataGrid的程序对&lt;%# DataBinder.Eval(Container.DataItem,"字段")%&gt;"&gt;语句的修改,使它能够正确显示.谢谢了!
2007-09-24 13:44
垃圾的沉默
Rank: 1
等 级:新手上路
威 望:2
帖 子:511
专家分:0
注 册:2007-6-25
收藏
得分:0 
合不合适是看你个人问题了..
<%# DataBinder.Eval(Container.DataItem,"字段")%>" 字段是你information里的列名.

人们笑我太疯癫...我笑人们太正经
2007-09-24 14:06
gaoqiang1987
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-9-23
收藏
得分:0 

这个我倒是知道,但是它原因出现在哪呢?我不知道,麻烦你再指点一下了,谢谢!代码如下:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="insertrecord.aspx.vb" Inherits="insertrecord" %>
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="system.data.oledb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="vbscript" type="text/vbscript" runat ="server">

Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
Dim myconnection As OleDbConnection
Dim mycommand As OleDbCommand
Dim myreader As OleDbDataReader
myconnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" & "h:\asp.net\information.mdb")
mycommand = New OleDbCommand("select * from information", myconnection)
myconnection.Open()
myreader = mycommand.ExecuteReader()
information.DataSource = myreader
information.DataBind()
End Sub
Sub information_pageindexchanged(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
information.CurrentPageIndex = e.NewPageIndex
DataBind()
End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>无标题页</title>
</head>

<body bgcolor="#990000" style="text-align: center">

<form id="form1" runat="server">
欢迎光临我的留言簿<br />
<asp:DataGrid runat="server"
CellPadding="3"
CellSpacing="0"
Font-Size="10pt"
HeaderStyle-BackColor="#aaaadd"
AlternatingItemStyle-BackColor="#eeeeee"

ID="information" AllowPaging="true" PageSize="3" ShowHeader="true"
OnPageIndexChanged="information_pageindexchanged">
<Columns>
<ItemTemplate>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>
<%# DataBinder.Eval(Container.DataItem,"name")%>">
</td>
</tr>
</table>
</ItemTemplate>
</Columns>
</asp:DataGrid>
&nbsp;
</form>

</body>
</html>

2007-09-24 14:45
垃圾的沉默
Rank: 1
等 级:新手上路
威 望:2
帖 子:511
专家分:0
注 册:2007-6-25
收藏
得分:0 
Sub page_load(ByVal sender As Object, ByVal e As EventArgs)
Dim myconnection As OleDbConnection
Dim mycommand As OleDbCommand
Dim myreader As OleDbDataReader
myconnection = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="server.Mappath("asp.net\information.mdb"))
myconnection.Open()
mycommand = New OleDbCommand("select * from information", myconnection)
myreader = mycommand.ExecuteReader()
information.DataSource = myreader
information.DataBind()
End Sub
你试一下吧..

人们笑我太疯癫...我笑人们太正经
2007-09-24 15:19
gaoqiang1987
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-9-23
收藏
得分:0 
还是不行,一样的问题,我觉得问题就在&lt;%# DataBinder.Eval(Container.DataItem,"name")%&gt;"&gt; 上.     
2007-09-24 15:34
垃圾的沉默
Rank: 1
等 级:新手上路
威 望:2
帖 子:511
专家分:0
注 册:2007-6-25
收藏
得分:0 
E-Mail多少..我发一份我写过的留板给你.

人们笑我太疯癫...我笑人们太正经
2007-09-24 15:50
快速回复:[求助]请问这个DataGrid怎么不显示?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031154 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved