Hi,
Here I am coding how to disable a html checkbox in gridview such that user cannot select or unselect the checkbox. Here I am coding this for disable and stop the operations of the HTML Checkbox control in ASP.Net gridview.


Aspx :

<html>
<head runat="server">
    <title>fourthbottle.com</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grd_popup_details" HeaderStyle-BackColor="#cccccc" runat="server"
            OnRowDataBound="grd_popup_details_RowDataBound" AutoGenerateColumns="false">
            <Columns>
                <asp:TemplateField ItemStyle-Wrap="false" HeaderText="Select">
                    <ItemTemplate>
                          <input id="CHK_CLR" type="checkbox"  runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField HeaderText="Description" DataField="Description" />
            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>
</html>

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI.HtmlControls;

namespace TTip
{
    public partial class pge2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection("connection string");
            string Query = "select Query";
            SqlDataAdapter da = new SqlDataAdapter(Query, con);
            DataSet DS = new DataSet();
            con.Open();
            da.Fill(DS);
            grd_popup_details.DataSource = DS;
            grd_popup_details.DataBind();
            con.Close();

            //method 1
            foreach (GridViewRow row in grd_popup_details.Rows)
            {
                var cb_clr = (HtmlInputCheckBox)row.FindControl("CHK_CLR");
                cb_clr.Disabled = true;
            }
        }

        //method 2
        protected void grd_popup_details_RowDataBound(object sender, GridViewRowEventArgs e)
        {
           e.Row.Cells[0].Attributes["disabled"] = "disabled";
        }
    }
}