sqladapter.Fill(dsTemp, "table")
Catch ex As SqlException
dsTemp.Tables.Add()
Finally
sqladapter.Dispose()
sqlcon.Close()
sqlcon.Dispose()
End Try
Return dsTemp.Tables("table")
End Function
End Class
4.2 填充下拉列表框
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
BindDrpClass()
End If
End Sub
Private Sub BindDrpClass()
Dim dt As DataSet
Dim sql As String = "select * from catalogs"
dt = DBcon.SelectCMD(Sql)
DropDownList1.Items.Clear()
DropDownList1.Items.Add(New ListItem("添加根栏目", "0"))
Dim par As Integer = 0
Dim drs As DataRow() = dt.Tables(0).Select("parentid=" & par)
For Each dr As DataRow In drs
Dim classid As String = dr("catalogID").ToString()
Dim classname As String = dr("catalogName").ToString()
'顶级分类显示形式
classname = "╋" + classname
|