Hi,
You can Try below code, where i fill the gridview by using DataAdapter.
1. define connection string in web.config file.
<connectionstrings>
<add name="ConnectionStringName" connectionstring="Data Source=abc;Initial Catalog=xyz;User ID=mno;Password=pqr" />
</connectionstrings>
2. Import some namespace.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
3. Now call function BindGridView(COOP_ID) to fill GridView by using DataAdapter, where i am passing COOP_ID = 1 you can pass as per your need.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
GridView1.DataSource = BindGridView(1)
GridView1.DataBind()
End Sub
Private Function BindGridView(ByVal COOP_ID As Integer) As DataTable
Dim connstr = ConfigurationManager.ConnectionStrings("ConnectionStringName").ConnectionString
Dim con As SqlConnection = New SqlConnection(connstr)
Dim da As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM tblEjemplo WHERE COOP_ID = " + COOP_ID + "", con)
Dim dt As New DataTable()
da.Fill(dt)
Return dt
End Function