Hi phonghue,
Check this example. Now please take its reference and correct your code.
HTML
C#
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="Yes / No">
<ItemTemplate>
<asp:Label Text='<%# Convert.ToBoolean(Eval("IsActive"))? "Yes" : "No" %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
VB.Net
<asp:GridView runat="server" ID="gvDetails" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:TemplateField HeaderText="Yes / No">
<ItemTemplate>
<asp:Label Text='<%# If(Convert.ToBoolean(Eval("IsActive")) = True , "Yes", "No") %>'
runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
System.Data.DataTable dt = new System.Data.DataTable();
dt.Columns.Add(new System.Data.DataColumn("Id"));
dt.Columns.Add(new System.Data.DataColumn("Name"));
dt.Columns.Add(new System.Data.DataColumn("IsActive"));
dt.Rows.Add(1, "John", true);
dt.Rows.Add(2, "Robert", false);
gvDetails.DataSource = dt;
gvDetails.DataBind();
}
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim dt As System.Data.DataTable = New System.Data.DataTable()
dt.Columns.Add(New System.Data.DataColumn("Id"))
dt.Columns.Add(New System.Data.DataColumn("Name"))
dt.Columns.Add(New System.Data.DataColumn("IsActive"))
dt.Rows.Add(1, "John", True)
dt.Rows.Add(2, "Robert", False)
gvDetails.DataSource = dt
gvDetails.DataBind()
End If
End Sub
Screenshot