GridView in VB.NET is the same control as DataGridView in Visual Studio Desktop. Rule of control’s filling is the same as in VB, but DataBing had to be add to got result.
Attention! This post has been published on my old website that has been down. I’m archiving old not verified posts for possible future use. Please be careful when using this post content.
Needed information got from this website:
MySQL data downloading and adding them to GridView:
Imports MySql.Data.MySqlClient Imports System.Data Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim conn As MySqlConnection = New MySqlConnection() ' forgot source conn.ConnectionString = "Data Source=Localhost; Database=tornado; Uid=root; Pwd=Pass;" Dim dt As New DataTable Try conn.Open() Try Dim adapter As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM modele", conn) adapter.Fill (dt) GridView2.DataSource = dt GridView2.DataBind() Catch ex1 As Exception MsgBox (ex1.Message) End Try Catch ex As Exception MsgBox (ex.Message) End Try End Sub End Class
However added GridView to our web page it is left alignment by default. Therefor to source code was added centering of GridView. Solution has been taken from this website: