【发布时间】:2013-02-27 19:53:34
【问题描述】:
我有一个包含 2 个下拉菜单、2 个文本框和一个按钮的页面。用户将从下拉列表中选择项目,然后在文本框中键入数据。这样做之后,他们将单击一个按钮以从这些控件中获取信息并填充“订单容器”。他们将能够输入多个“订单”。
- Gridview 控件是否会成为此“订单容器”的路径?
- Gridview 控件是否允许我插入多条记录?
- Gridview 控件是否允许删除记录?
感谢您的帮助! 迈克
更新: 以下是我更新 gridview 的方式:
Protected Sub imgAddOrderItemClick(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles imgAddOrderItem.Click
Dim qty As String 'Integer
Dim type As String
Dim product As String
Dim price As Integer
Dim count As Integer
count = GridView1.Rows.Count
type = ddlProductTypes.SelectedItem.ToString
product = ddlProductFamilies.SelectedItem.ToString
price = 11
qty = TextBox10.Text
' Populate the datatable with your data (put this in appropriate loop)
dr = dt.NewRow
dr("Type") = type
dr("Product") = product
dr("Qty") = qty
dr("Price") = price
' Add the row
dt.Rows.Add(dr)
dt.AcceptChanges()
GridView1.DataSource = dt 'GetData()
GridView1.DataBind()
End Sub
【问题讨论】:
-
我不认为
GridView允许您插入记录。您最好查看ListView控件。 -
我已经能够向 Gridview 添加一行,但只能添加一行。如果我有第二行,它将覆盖现有行。
-
我正在添加这样的新行:
-
您可以使用 GridView 插入和删除多行。只需在代码隐藏中将行添加/删除到您的数据源。
-
谢谢。我很感激。
标签: asp.net