您正在尝试使用具有 3 个参数的DataTable.Columns.Add()方法,如下所示:
Public DataColumn Add(ByVal columnName As String, ByVal type As Type, ByVal expression As String)
由于第三个表达式是 a String,因此您不能使用TextBoxobject fromSystem.Web.UI.WebControls添加到该列中。但是,您可以将文本框属性中Integer的值添加到在代码隐藏中使用行索引和列名:TextDataRowCollection
Dim dt As New DataTable()
' declare other 5 columns first
' assume 'Quantity' is the 6th column (index 5)
dt.Columns.Add("Quantity",Type.GetType("System.Int32"))
' example to fill first row (index 0)
' Convert.ToInt32 or Integer.TryParse may be used too
dt(0)("Quantity") = Integer.Parse(myfield.Text)