You can try this,
<asp:GridView ID="gvBranches" runat="server" AutoGenerateColumns="False" CellPadding="4"
Font-Names="Verdana" Font-Size="11px" GridLines="None"
Width="182px">
<Columns>
<asp:TemplateField HeaderText="Check_All">
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" onclick="checkAll(this);" />
</HeaderTemplate>
<ItemStyle HorizontalAlign="Left" Width="30px" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" />
<ItemTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" onclick="Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Column">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text="Some Value"></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
</Columns>
</asp:GridView>
And js functions are like,
<script type="text/javascript">
function checkAll(objRef) {
var GridView = objRef.parentNode.parentNode.parentNode;
var inputList = GridView.getElementsByTagName("input");
var c = 0;
for (var i = 0; i < inputList.length; i++) {
var row = inputList[i].parentNode.parentNode;
if (inputList[i].type == "checkbox" && objRef != inputList[i]) {
if (objRef.checked) {
c = 1;
inputList[i].checked = true;
}
else {
c = 0;
inputList[i].checked = false;
}
}
}
}
function Check_Click(objRef) {
var row = objRef.parentNode.parentNode;
var GridView = row.parentNode;
var inputList = GridView.getElementsByTagName("input");
var c = 0;
inputList[0].checked = true;
for (var i = 1; i < inputList.length; i++) {
if (inputList[i].type == "checkbox" && inputList[i].checked == true) {
c = 1;
}
else {
inputList[0].checked = false;
}
}
}
</script>