Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Show_word()
End If
End Sub
Private Sub Show_word()
Dim sql As String = "SELECT * FROM Table ORDER BY ID ASC"
Dim dt As DataTable = New DataTable()
Dim adap As SqlDataAdapter = New SqlDataAdapter(sql, conn.dbconn)
adap.Fill(dt)
If dt.Rows.Count > 0 Then
ddl_word.DataSource = dt
ddl_word.DataTextField = "Name"
ddl_word.DataValueField = "ID"
ddl_word.DataBind()
ddl_word.Items.Add("")
ddl_word.SelectedIndex = ddl_word.Items.IndexOf(ddl_word.Items.FindByValue(""))
End If
End Sub
Public Shared Function SortDatatable(ByVal dt_data As DataTable, ByVal sort_field As String, Optional ByVal sort_direction As String = "ASC") As DataTable
Dim dv_data As New DataView
dv_data = dt_data.DefaultView
dv_data.Sort() = sort_field & " " & sort_direction
dt_data = dv_data.ToTable()
Return dt_data
End Function