There are two ways of binding datagrid in asp.net
1) Data reader
2) Data adapter
HTML Code:
Imports System.Data.SqlClient
For select query to a SQL database, you must create a SqlConnection to the database passing the connection string, and then construct a SqlDataAdapter object that contains your query statement. To populate a DataSet object with the results from the query, you call the command's Fill method.
Dim cn As New SqlConnection("server=yourservername;database=pubs;uid=username;pwd=")
cn.Open()
Dim cmd As New SqlDataAdapter("select * from Authors", cn)
Dim ds As New DataSet()
cmd.Fill(ds, "Authors")
The advantage of using a dataset is that it gives you a disconnected view of the database. You can operate on a dataset in your application, and then
reconcile your changes with the actual database later.
DataGrid1.DataSource=ds.Tables("authors")
DataGrid1.DataBind()
Hope it will help you bind grid using asp.net It is a code in vb.net you can convert it using c#