加上:
if not IsPostBackmydatagrid 换成“myDataGrid”试试!
if not IsPostBackmydatagrid 换成“myDataGrid”试试!
解决方案 »
- 如何在girdview添加的buttonfield按钮中写事件啊???急
- 我用VB生成了一个DLL文件 , 在asp.net(C#)中实例化时就出错。请问这什么情况?
- DropDownList控件可以绑定日期控件吗??
- GridView如何突出显示当前页数?
- 100分,求未能加载文件或程序集的错误的解决方法
- 分不多了:求brightheroes(闭关|那一剑的风情)
- GridView问题
- treeview绑定到了数据库,也成功显示出了数据,只是显示不完全,只能显示出前几个,不知道这是为什么?
- 帮我译文
- ASP.Net下用户验证与管理专题讨论(包括角色和权限)。
- ASPX页面怎样获得Cookie的值?
- 关于treeview右健菜单的问题
把mydatagrid.datasource=ds.tables("employees").defaultview改成mydatagrid.datasource=ds 试试
dim myConnection as SQLConnection
dim mycommand as SqlCommand
dim sqladt as sqldataadapter
myconnection=new sqlconnection("server=localhost;uid=sa;pwd=1111;database=northwind")
mycommand=new SqlCommand("select * from employees",myconnection)
sqladt = new sqldataadapter(mycommand)
ds=new dataset()
sqladt.fill(ds,"employees")试试这样应该行了。
改成mydatagrid.datasource=ds 也不行。
会不会是
mydatagrid.datasource=ds.tables("employees").defaultview
mydatagrid.databind()
的问题啊
if not page.IspostBack then
dim ds as dataset
dim myConnection as SQLConnection
dim mycommand as sqldataadapter
myconnection=new sqlconnection("server=localhost;uid=sa;pwd=1111;database=northwind")
mycommand=new sqldataadapter("select * from employees",myconnection)
ds=new dataset()
mycommand.fill(ds,"employees")
mydatagrid.datasource=ds.tables("employees").defaultview
mydatagrid.databind()
end if
end sub
</script>改成%>s试试
我也不知道为什么
但有一次我也是这样的
这是例子,我就是按照这段修改的:<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %><html>
<script language="VB" runat="server"> Sub Page_Load(Sender As Object, E As EventArgs) Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyCommand As SqlDataAdapter MyConnection = New SqlConnection("server=(local)\NetSDK;database=pubs;Trusted_Connection=yes")
MyCommand = New SqlDataAdapter("select * from Authors", MyConnection) DS = new DataSet()
MyCommand.Fill(ds, "作者") MyDataGrid.DataSource=ds.Tables("作者").DefaultView
MyDataGrid.DataBind()
End Sub</script><body> <h3><font face="宋体">DataGrid 控件的简单选择</font></h3> <ASP:DataGrid id="MyDataGrid" runat="server"
Width="700"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="宋体"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/></body>
</html>
mydatagrid.datasource=ds
end if不行吗
真不行。我就纳闷了。这样吧,那位高手好心,写个小程序让我看看,我琢磨琢磨。50分,以能运行为准。
就用SQL SERVER自带的例子数据库northwind,employees表。用datagrid显示出所有的内容。
谢谢
就是把
sub page_load(sender as object,e as eventargs)
dim ds as dataset
dim myConnection as SQLConnection
dim mycommand as sqldataadapter
myconnection=new sqlconnection("server=localhost;uid=sa;pwd=1111;database=northwind")
mycommand=new sqldataadapter("select * from employees",myconnection)
ds=new dataset()
mycommand.fill(ds,"employees")
mydatagrid.datasource=ds.tables("employees").defaultview
mydatagrid.databind()
end sub剪切到WebForm15.aspx.vb里面就可以了。