In order to implement it through codebehind please find below steps:
Step1: Add OnRowDataBound property in griview.
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" onrowdatabound="GridView1_RowDataBound" cellpadding="4" forecolor="#333333" gridlines="None" xmlns:asp="#unknown">
<columns>
<asp:boundfield datafield="UserId" headertext="User Id" />
<asp:templatefield headertext="Select">
<itemtemplate>
<asp:checkbox id="chkSelect" runat="server" />
</itemtemplate>
</asp:templatefield></columns>
</asp:gridview>
Step2: Add OnRowDataBound method in code behind.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
((CheckBox)e.Row.FindControl("chkSelect")).Checked = Convert.ToBoolean(((DataRowView)e.Row.DataItem)[1]);
}
}
http://www.c-sharpcorner.com/uploadfile/MohanKumar.R/selecting-checkboxes-inside-the-gridview-control/[
^]