here is overview: 1. RadGrid is generated with values from database 2. one of columns in RadGrid is "itemtemplate checkbox column" which is unchecked on load 3. there are a textbox outside RadGrid which needs to be updated with following value ( total rows checked )
if user check a checkbox, rowcount must be updated to textbox.
kindly assist.
safie.
here is a solution , It should be fired ASAP checkbox has been checked or unchecked.
function Checked() {
var grid = $find("<%=RadGrid1.ClientID %>");
var count = 0;
var masterTable = grid.get_masterTableView();
for (var i = 0; i < masterTable.get_dataItems().length; i++) {
var gridItemElement = masterTable.get_dataItems()[i].findElement("chkToFind");
if (gridItemElement.checked) {
count++;
}
}
//update the text box with count value
txtBox.value=count;
}
Let me know if you have any concerns.
Try this :
In itemTemplate
checkbox make auto-postback true
and onCheckedChange event
count the number of checked rows of Grid
and update textbox's text
with that number. For example :
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" />
</ItemTemplate>
Now, take a RadAjaxManager
and Its ajax settings
add the gridview
and pass the textbox
name in UpdatedControls
pass the textbox's Id
and grid's Id
. For example :
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="GridId">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="TextBoxId" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="GridId" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
In .cs page
protected void ToggleSelectedState(object sender, EventArgs e)
{
// Count the grid's checked rows and update texbox here.
}
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.