Change 1 as Enabled and 0 as disabled while binding the grid for a column
<p>I am having a grid and below is the code which I had written for it. In my grid for this column i.e. <code>&lt;asp:BoundField DataField = "IsNOWEnabled" HeaderText = "Enabled/Disabled"  HtmlEncode = "true"/&gt;</code> , from the database either 1 or 0 is coming. I want that while the binding the grid replace the text 1 by enabled and 0 by disabled for this column so that when the grid binds it display 1 as enabled and 0 as disabled for column Enabled/Disabled.</p>

<p>Please guide me , how i achieve this.</p>

<pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
&lt;ContentTemplate&gt;
    &lt;asp:GridView ID="GridView1" runat="server"  Width = "550px" AutoGenerateColumns = "false"  AlternatingRowStyle-BackColor = "#C2D69B" HeaderStyle-BackColor = "green" AllowPaging ="true" OnPageIndexChanging = "OnPaging" PageSize = "10" &gt;
        &lt;Columns&gt;
            &lt;asp:BoundField DataField = "NatureOfWorkID" HeaderText = "Nature Of WorkID" HtmlEncode = "true" Visible="false" /&gt;
            &lt;asp:BoundField DataField = "NatureOFWorkName" HeaderText = "Nature Of Work Name"  HtmlEncode = "true" /&gt;    
            &lt;asp:BoundField DataField = "IsNOWEnabled" HeaderText = "Enabled/Disabled"  HtmlEncode = "true"/&gt; 
            &lt;asp:TemplateField ItemStyle-Width = "30px"  HeaderText = "NatureOfWorkID"&gt;
               &lt;ItemTemplate&gt;
                   &lt;asp:LinkButton ID="lnkEdit" runat="server" Text = "Edit" OnClick = "Edit"&gt;&lt;/asp:LinkButton&gt;
               &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
        &lt;/Columns&gt; 
        &lt;AlternatingRowStyle BackColor="#C2D69B"  /&gt;
    &lt;/asp:GridView&gt;
    &lt;asp:Button ID="btnAdd" runat="server" Text="Add" OnClick = "Add" /&gt;
    &lt;asp:Panel ID="pnlAddEdit" runat="server" CssClass="modalPopup" style = "display:none"&gt;
    &lt;asp:Label Font-Bold = "true" ID = "Label4" runat = "server" Text = "Nature Of Work Details" &gt;&lt;/asp:Label&gt;
    &lt;br /&gt;
        &lt;table align = "center"&gt;      
            &lt;tr&gt;
                &lt;td&gt;
                &lt;asp:Label ID = "Label2" runat = "server" Text = "Nature Of Work Name" &gt;&lt;/asp:Label&gt;
                &lt;/td&gt;
                &lt;td&gt;
                &lt;asp:TextBox ID="txtNOWname" runat="server"&gt;&lt;/asp:TextBox&gt;    
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td&gt;
                    &lt;asp:RadioButton id="RBEnable" Text="Enabled"  runat="server"/&gt;
                    &lt;br&gt;
                    &lt;asp:RadioButton id="RBDisable" Text="Disabled"  runat="server"/&gt;
                    &lt;br&gt;
                &lt;/td&gt;            
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td&gt;
                &lt;asp:Button ID="btnSave" runat="server" Text="Save" OnClick = "Save" /&gt;
                &lt;/td&gt;
                &lt;td&gt;
                &lt;asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClientClick = "return Hidepopup()"/&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/table&gt;
    &lt;/asp:Panel&gt;
    &lt;asp:LinkButton ID="lnkFake" runat="server"&gt;&lt;/asp:LinkButton&gt;
        &lt;cc1:ModalPopupExtender ID="popup" runat="server" DropShadow="false"
        PopupControlID="pnlAddEdit" TargetControlID = "lnkFake"
        BackgroundCssClass="modalBackground"&gt;
        &lt;/cc1:ModalPopupExtender&gt;
&lt;/ContentTemplate&gt; 
    &lt;Triggers&gt;
    &lt;asp:AsyncPostBackTrigger ControlID = "GridView1" /&gt;
    &lt;asp:AsyncPostBackTrigger ControlID = "btnSave" /&gt;
    &lt;/Triggers&gt; 
</code></pre>

<p> </p>

<p>The code behind is :-</p>

<pre><code>private String strConnString = ConfigurationManager.ConnectionStrings["TempConnectionString"].ConnectionString;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.BindData();
        }
    }

    private void BindData()
    {
        string strQuery = "select NatureOfWorkID,NatureOfWorkName,IsNOWEnabled" +
                           " from NatureOfWork";
        SqlCommand cmd = new SqlCommand(strQuery);
        GridView1.DataSource = GetData(cmd);
        GridView1.DataBind();
    }

    private DataTable GetData(SqlCommand cmd)
    {
        DataTable dt = new DataTable();
        using (SqlConnection con = new SqlConnection(strConnString))
        {
            using (SqlDataAdapter sda = new SqlDataAdapter())
            {
                cmd.Connection = con;
                con.Open();
                sda.SelectCommand = cmd;
                sda.Fill(dt);
                return dt;
            }
        }
    }

    protected void OnPaging(object sender, GridViewPageEventArgs e)
    {
        this.BindData();
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
</code></pre>
