Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page

MyConnection = New Odbc.OdbcConnection("STMT=;OPTION=3;DSN=mysql;UID=;DESC=MySQL ODBC 3.51 Driver DSN;DATABASE=test;SERVER=localhost;PORT=3306")

'BindGrid()

If Not (IsPostBack) Then

BindGrid("id")

End If

 

End Sub

 

 

Sub DataGrid1_Sort(ByVal Sender As Object, ByVal E As DataGridSortCommandEventArgs)

BindGrid(E.SortExpression)

End Sub

 

Sub BindGrid(ByVal SortField As String)

 

Dim DS As DataSet

Dim MyCommand As Odbc.OdbcDataAdapter

MyCommand = New Odbc.OdbcDataAdapter("select * from item", MyConnection)

 

DS = New DataSet

MyCommand.Fill(DS, "item")

 

Dim Source As DataView = DS.Tables("item").DefaultView

Source.Sort = SortField

 

DataGrid1.DataSource = Source

DataGrid1.DataBind()

End Sub

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...