我有一组 asp 隐藏字段控件,我希望根据我的数据表列名设置值,返回的列数不同,所以如果不使用,我将未使用的隐藏字段设置为 0。以下是我迄今为止所做的尝试,只是努力相应地设置正确的隐藏字段。
VB-
Dim dt As DataTable
Dim ds As New DataSet()
ds = Getdata(4)
dt = ds.Tables(0)
Dim ColCnt As String = dt.Columns.Count 'Current ColCnt is 3
For Each column As DataColumn In dt.Columns
Select Case ColCnt
Case 2
hxValue.Value = column.ColumnName 'set to 1st Column Name
hxValue1.Value = 0 'Not used
hyValue.Value = column.ColumnName 'Set To 2nd Column Name
Case 3
hxValue.Value = column.ColumnName 'set to 1st Column Name
hxValue1.Value = column.ColumnName 'set to 2nd Column Name
hyValue.Value = column.ColumnName 'set to 3rd Column Name
End Select
Next