标题:斑竹,没人帮我,您拉我一把吧!
取消只看楼主
zhanglindezz
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2004-11-3
 问题点数:0 回复次数:1 
斑竹,没人帮我,您拉我一把吧!
下面的程序,点击“Add”增加了一个行,点击“AddOther”增加行的时候,“Add”增加的行就没有了。我想让这两个行都显示在页面里面。

<%@ Page Language="VB" %> <%@ import Namespace="System.Data" %> <script runat="server">

Dim dtblCart As DataTable Dim dcolColumn As DataColumn Dim dvwCart As DataView Sub Page_Load ' Create DataTable dtblCart = New DataTable( "Cart" ) Dim drowItem As DataRow ' Create Columns dcolColumn = New DataColumn( "ProductID", GetType( Int32 ) ) dtblCart.Columns.Add( dcolColumn ) dcolColumn = New DataColumn( "ProductName", GetType( String ) ) dtblCart.Columns.Add( dcolColumn ) dcolColumn = New DataColumn( "ProductCategory", GetType( String ) ) dtblCart.Columns.Add( dcolColumn ) dcolColumn = New DataColumn( "ProductPrice", GetType( Decimal ) ) dtblCart.Columns.Add( dcolColumn ) End SUb Sub Add(s As object,e As EventArgs) Dim drowItem As DataRow drowItem = dtblCart.NewRow() drowItem(0) = 0 drowItem(1) = 1 drowItem(2) = 2 drowItem(3) = 3 dtblCart.Rows.Add(drowItem) dvwCart = dtblCart.Defaultview dgrdCart.DataSource = dvwCart dgrdCart.DataBind() End Sub

Sub AddOther(s As object,e As EventArgs) drowItem = dtblCart.NewRow() drowItem(0) = "11" drowItem(1) = "c" drowItem(2) = "v" drowItem(3) = "22" dtblCart.Rows.Add(drowItem) dvwCart = dtblCart.Defaultview dgrdCart.DataSource = dvwCart dgrdCart.DataBind() End Sub </script> <html> <head> </head> <body> <form runat="server"> <asp:DataGrid id="dgrdCart" Runat="Server"></asp:DataGrid> <asp:linkButton id="btnAdd" onclick="Add" Runat="Server" Text="Add"/> <asp:LinkButton id = "btnAddOther" OnClick = "AddOther" Runat = "Server" Text = "AddOther"/> </form> </body> </html> 请指点一下!谢谢!

搜索更多相关主题的帖子: Dim DataTable 斑竹 New 
2004-11-07 18:04
zhanglindezz
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2004-11-3
得分:0 

谢谢大家来看我的贴子,可悲啊,还是没人理我,我自己已经搞定了,把dtblCart加到session里就可以了。

2004-11-07 20:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-7277-1-1.html




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

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