3 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 24 Nov 2009, 08:05 AM
Hello Venkata,
Do you use GridClientSelectColumn checkboxes or Checkboxes nested inside the GridTemplateColumn? Anyways, here's examples for both sceanrios.
aspx:
-To check the checkboxes in the child grid's TemplateColumn on clicking on a button outside the grid:
c#:
-To check the GridClientSelectColumn checkboxes in the child grid's TemplateColumn on clicking on a button outside the grid:
c#:
Thanks
Princy.
Do you use GridClientSelectColumn checkboxes or Checkboxes nested inside the GridTemplateColumn? Anyways, here's examples for both sceanrios.
aspx:
| <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">CheckAll</asp:LinkButton> |
| <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" AutoGenerateColumns="true" runat="server"> |
| <MasterTableView DataSourceID="SqlDataSource1" Name="Master"> |
| <DetailTables> |
| <telerik:GridTableView DataSourceID="SqlDataSource1" Name="Detail" runat="server"> |
| <Columns> |
| <telerik:GridTemplateColumn UniqueName="CheckBoxColumn"> |
| <ItemTemplate> |
| <asp:CheckBox ID="CheckBox1" runat="server" /> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridClientSelectColumn UniqueName="SelectColumn"></telerik:GridClientSelectColumn> |
| </Columns> |
| ..... |
-To check the checkboxes in the child grid's TemplateColumn on clicking on a button outside the grid:
c#:
| protected void LinkButton1_Click(object sender, EventArgs e) |
| { |
| foreach (GridDataItem item in RadGrid1.Items) |
| { |
| if (item.OwnerTableView.Name == "Detail") |
| { |
| CheckBox chk = (CheckBox)item.FindControl("CheckBox1"); |
| chk.Checked = true; |
| } |
| } |
| } |
-To check the GridClientSelectColumn checkboxes in the child grid's TemplateColumn on clicking on a button outside the grid:
c#:
| protected void LinkButton1_Click(object sender, EventArgs e) |
| { |
| foreach (GridDataItem item in RadGrid1.Items) |
| { |
| if (item.OwnerTableView.Name == "Detail") |
| { |
| item.Selected = true; |
| } |
| } |
| } |
Thanks
Princy.
0
Venkata
Top achievements
Rank 1
answered on 24 Nov 2009, 02:55 PM
not working..
foreach (GridDataItem item in rgdShowExcerpts.Items)
{
if (item.OwnerTableView.Name == "grdCitations")
{
item.Selected = true;
}
}
item.OwnerTableView.Name always showing "Master" value
any thing i am doing wrong?
0
Shinu
Top achievements
Rank 2
answered on 25 Nov 2009, 12:35 PM
Hi Venkata,
The above code will work, when the button is clicked after the items are already expanded. If you want to expand the child items and then check all the checkboxes, then you can try the following code.
CS:
Hope this helps,
Shinu.
The above code will work, when the button is clicked after the items are already expanded. If you want to expand the child items and then check all the checkboxes, then you can try the following code.
CS:
| protected void Button1_Click(object sender, EventArgs e) |
| { |
| foreach (GridDataItem item in RadGrid1.Items) |
| { |
| if (!item.Expanded) |
| { |
| item.Expanded = true; |
| GridTableView childtable = (GridTableView)item.ChildItem.NestedTableViews[0]; |
| foreach(GridDataItem childitem in childtable.Items) |
| { |
| childitem.Selected = true; |
| } |
| } |
| } |
| } |
Hope this helps,
Shinu.