Hi Allen,
I have created sample refer the below code.
HTML
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowDataBound="RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkbxlate" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Id" HeaderText="Id" />
<asp:BoundField DataField="Name" HeaderText="Name" />
<asp:BoundField DataField="Time" HeaderText="Country" />
</Columns>
</asp:GridView>
</div>
Code
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Time",typeof(TimeSpan)) });
dt.Rows.Add(1, "John Hammond", new TimeSpan(09, 35, 00));
dt.Rows.Add(2, "Mudassar Khan", new TimeSpan(09, 30, 00));
dt.Rows.Add(3, "Suzanne Mathews", new TimeSpan(10, 00, 00));
dt.Rows.Add(4, "Robert Schidner", new TimeSpan(09, 29, 00));
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CheckBox chkLate = e.Row.FindControl("chkbxlate") as CheckBox;
TimeSpan time = TimeSpan.Parse(e.Row.Cells[3].Text.Trim());
TimeSpan timeToCompare = new TimeSpan(09, 30, 00);
if (time > timeToCompare)
{
chkLate.Checked = true;
}
}
}
Screenshot