5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 30 Oct 2008, 05:18 AM
Hello,
You can try out the following code to checkmark the checkbox in the TemplateColumn on clicking a button. The code shows how to checkmark the checkbox for the row in which the button is clicked.
aspx:
cs:
Thanks
Princy.
You can try out the following code to checkmark the checkbox in the TemplateColumn on clicking a button. The code shows how to checkmark the checkbox for the row in which the button is clicked.
aspx:
<telerik:GridTemplateColumn UniqueName="TemplateColumn3"> |
<ItemTemplate> |
<asp:CheckBox ID="CheckBox1" runat="server" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
cs:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Check") |
{ |
GridDataItem item = (GridDataItem)e.Item; |
CheckBox chk = (CheckBox)item.FindControl("CheckBox1"); |
chk.Checked = true; |
} |
} |
Thanks
Princy.
0
Omarr
Top achievements
Rank 1
answered on 30 Oct 2008, 01:58 PM
What I understand from the code you provided that the button is also included in the same row. This is not what I require. There is another button, outside the grid which handles the checking of the checkboxes in a grid. There is some more logic which calculates the checkstate of checkboxes amd check/uncheck them accordingly.
0
Omarr
Top achievements
Rank 1
answered on 30 Oct 2008, 02:00 PM
And not to forget the checkboxes exist on the rows of the child grid. (I am using hierarchical grids)
0
Hello Omarr,
Please test the attached example.
Additionally I suggest you examine the following document:
Traversing detail tables/items in Telerik RadGrid
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please test the attached example.
Additionally I suggest you examine the following document:
Traversing detail tables/items in Telerik RadGrid
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Shinu
Top achievements
Rank 2
answered on 31 Oct 2008, 04:36 AM
Hi Omarr,
Try the following code snippet to achieve the desired scenario.
ASPX:
CS:
Regards
Shinu.
Try the following code snippet to achieve the desired scenario.
ASPX:
<DetailTables > |
<telerik:GridTableView DataSourceID="SqlDataSource1" Name="Detail" runat="server" > |
<Columns> |
<telerik:GridTemplateColumn UniqueName="MyTempCol" > |
<ItemTemplate> |
<asp:CheckBox ID="CheckBox2" runat="server" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
</telerik:GridTableView> |
</DetailTables> |
CS:
protected void Button1_Click(object sender, EventArgs e) |
{ |
foreach (GridItem item in RadGrid1.Items) |
{ |
if (item.OwnerTableView.Name == "Detail") |
{ |
GridDataItem childitem = (GridDataItem)item; |
CheckBox chkbx2 = (CheckBox)childitem["MyTempCol"].FindControl("CheckBox2"); |
chkbx2.Checked = !chkbx2.Checked; |
} |
} |
} |
Regards
Shinu.