GridView BoundField Example in ASP.NET C#

March 06, 2016 , 0 Comments

In this article i will show you, How to use BoundField of GridView in ASP.NET C#. Actually, BoundField is the Default field of GridView Control, used for DataBinding purpose. In my previous article i have already use this field with SQL DataSource control. Check mentioned below link:

[Video Contain BoundField + SQLDataSource + ADO.NET]

Now, Learn, How to create BoundField manually also bind them using ADO.NET Technology with Database table. First to create a database table, insert some data into table. Prepare BoundField like this:

  <asp:GridView ID="g1" runat="server" AutoGenerateColumns="false">

            <asp:BoundField DataField="Id" HeaderText="Identification No" />
            <asp:BoundField DataField="Name" HeaderText="Name of User" />


Code Behind Code:

using System;
using System.Web.UI;
using System.Data.SqlClient;
using System.Configuration;

public partial class BoundFieldExample : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)

    private void bindGrid()
        SqlConnection con = new SqlConnection();
        con.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
        SqlCommand cmd= new SqlCommand();
        cmd.CommandText = "select * From [usertable]";
        cmd.Connection =con;
        SqlDataReader rd= cmd.ExecuteReader();
        g1.DataSource =rd;

Code Generates the following output:

GridView BoundField Example in ASP.NET C#

Jacob Lefore

Some say he’s half man half fish, others say he’s more of a seventy/thirty split. Either way he’s a fishy bastard. Google