I didn't get your code...
but i think if i got your question...
Here is an Example...
<script type="text/javascript">
function CheckAll(obj) {
var list = document.getElementById("<%=DataGrid1.ClientID%>");
var chklist = list.getElementsByTagName("input");
for (var i = 0; i < chklist.length; i++) {
if (chklist[i].type == "checkbox" && chklist[i] != obj) {
chklist[i].checked = obj.checked;
}
}
}
</script>
For Header Template
<HeaderTemplate>
<asp:checkbox id="CheckBox1" onclick="CheckAll(this);" runat="server" xmlns:asp="#unknown" />
</HeaderTemplate>
for Item Template
<itemtemplate>
<asp:checkbox id="CheckBox2" runat="server" xmlns:asp="#unknown" />
</itemtemplate>
on Submit Button Check - if checkbox of that row is checked then perform your action