0
我有一套asp隱藏字段控件,我希望根據我的數據表列名設置值,返回的列數不同,所以我是如果未使用,則將未使用的隱藏字段設置爲0。以下是我迄今爲止試圖相應地設置正確隱藏字段的努力。VB.net將隱藏字段值設置爲有條件的數據表列名稱
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
完美的感謝@KPL – user1588253