hosting tips

ReliableHostingASP.NET Tutorial: Learn How to Make CheckBox ReadOnly in ASP.NET 4.6.1

ReliableHostingASP.NET Tutorial – This tutorial, describes how to set checkbox value ReadOnly on the basis of backend data. A checkbox (check box, tickbox, tick box) is a GUI widget that permits the user to make a binary choice, i.e. a choice between one of two possible mutually exclusive options. For example, the user may have to answer ‘yes’ (checked) or ‘no’ (not checked) on a simple yes/no question.

using System;  
using System.Collections.Generic;  
using System.Data;  
using System.Data.SqlClient;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Configuration;  

public partial class AttributesProperty: System.Web.UI.Page {  
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constring"].ConnectionString);  
protected void Page_Load(object sender, EventArgs e) {  
    if (!IsPostBack == true) {  
protected void BindData() {  
    try {  
        string strQuery = "select ID, Attributes, Properties from tblAttributes";  
        SqlCommand cmd = new SqlCommand(strQuery, con);  
        cmd.CommandType = CommandType.Text;  
        SqlDataAdapter da = new SqlDataAdapter(cmd);  
        DataTable dt = new DataTable();  
        AttributeGrid.DataSource = dt;  
    } catch (Exception ex) {  
        //throw ex;    
    } finally {  

protected void checkProperties_CheckedChanged(object sender, EventArgs e) {  
    CheckBox check = (CheckBox) AttributeGrid.FindControl("checkAttributes");  
    GridViewRow GrdRW = (GridViewRow) check.Parent.Parent;  
    if (check.Checked == true) {}  
protected void AttributeGrid_RowDataBound(object sender, GridViewRowEventArgs e) {  


        if (e.Row.RowType == DataControlRowType.DataRow) {  
            //Label a = (Label)DataBinder.Eval(e.Row.DataItem, "lblDept1");    
            var a = (Label) e.Row.FindControl("lblDept1");  
            string b = a.Text;  
            if (b == "0") {  
                ((CheckBox) e.Row.FindControl("checkProperties")).Checked = true;  
            } else if (b == "1") {  
                ((CheckBox) e.Row.FindControl("checkProperties")).Checked = false;  
            } else Response.Write("inavlid entry");  



Reliable ASP.NET 4.6.1 Hosting Recommendation