I have a checkbox column in my datagrid like so:
I want the ability to run a number of different functions on this page which will use the data specified by the checkbox boolean. I already have the grid using its row click selected event to load the nested view details, what I want now is the ability to get the row records associated with the checkboxes when something like a link button is clicked.
So how do I get the record integer value of all the checkboxes that are selected when my link button is clicked?
<Columns> |
<telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn"> |
<HeaderTemplate> |
<asp:CheckBox ID="cl" onclick="return check_uncheck (this );" runat="server" /> |
</HeaderTemplate> |
<ItemTemplate> |
<asp:CheckBox ID="chk_record" onclick="return check_uncheck (this );" runat="server" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridBoundColumn DataField="record" |
HeaderText="record" SortExpression="record" |
UniqueName="record" DataType="System.Int32" ReadOnly="True" |
Visible="False"> |
</telerik:GridBoundColumn> |
<script type="text/javascript"> |
function check_uncheck(Val) { |
var ValChecked = Val.checked; |
var ValId = Val.id; |
var frm = document.forms[0]; |
// Loop through all elements |
for (i = 0; i < frm.length; i++) { |
// Look for Header Template's Checkbox |
//As we have not other control other than checkbox we just check following statement |
if (this != null) { |
if (ValId.indexOf('cl') != -1) { |
// Check if main checkbox is checked, |
// then select or deselect datagrid checkboxes |
if (ValChecked) |
frm.elements[i].checked = true; |
else |
frm.elements[i].checked = false; |
} |
else if (ValId.indexOf('deleteRec') != -1) { |
// Check if any of the checkboxes are not checked, and then uncheck top select all checkbox |
if (frm.elements[i].checked == false) |
frm.elements[1].checked = false; |
} |
} // if |
} // for |
} // function |
</script> |
I want the ability to run a number of different functions on this page which will use the data specified by the checkbox boolean. I already have the grid using its row click selected event to load the nested view details, what I want now is the ability to get the row records associated with the checkboxes when something like a link button is clicked.
So how do I get the record integer value of all the checkboxes that are selected when my link button is clicked?
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click |
'how do I loop through all of the checkboxes and get the row key (record) for all of them that are selected? |
End Sub |