Saturday, July 29, 2017

// // 1 comment

How to bind data with Gridview using VB code



In this article I am going to explain, how to bind data with Gridview using code. In previous article
How to bind data with Gridview , I have explained data binding with data source.

First you have to create a new web project as we discussed earlier article. How to create new project with visual studio

Drag and drop Button control and Grid view control in to Design form.



with double clicking on Button control you can go to button click event coding window.

Imports System.Data
Imports System.Data.SqlClient
Imports Class1
Partial Class _Default
    Inherits System.Web.UI.Page
    Protected Sub btnView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnView.Click
        Dim ds As New SqlDataSource
        Dim QString As String
        QString = "SELECT [b_code], [b_name] FROM [Banks]"
        ds.ConnectionString = GetConnectionString()
        ds.SelectCommand = QString
        GridView1.DataSource = ds
        GridView1.DataBind()
    End Sub
End Class

I have explained how to get connection with database Table in previous article and also you can what the Video.

Watch Video






























1 comment:

  1. Grate article, thanks
    Watch Video https://youtu.be/E3rKc_dyrIM

    ReplyDelete