mardi 2 février 2016

convert column in Gridview to checkboxes

I have a gridview that displays a list of items and if they are checked or not. In the database the value is a boolean value. But in the GridView the column is displaying as true or false. How do I change it a checkbox instead of true/false.

<asp:BoundField DataField="Checked" HeaderText="Checked"></asp:BoundField>

Code behind:

 protected void gvCVRTDetails_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            lookupCVRT work = (lookupCVRT)e.Row.DataItem;
            GridView gv = sender as GridView;

            e.Row.Attributes.Add("ID", "gvCVRTDetails_" + work.ID);
            e.Row.Cells[0].Attributes.Add("onclick", "event.stopPropagation();");

            HtmlGenericControl lnkShowHide = (HtmlGenericControl)e.Row.FindControl("lnkShowHide");
            HyperLink ChecklistItem = (HyperLink)e.Row.FindControl("ID");


        }
    }  




Aucun commentaire:

Enregistrer un commentaire