Hi all!
I created a template for editmode. And set
When click on "Edit", it shows correctly what I designed.
But the Checkbox doesn't automatically checked.
I mean when I edit a specific row, the checkbox of that row should be set to TRUE. Please attack the pics!
(This problem doesn't happen when EditMode="InPlace")
Thanks!
Andy.
I created a template for editmode. And set
EditMode="EditForms"When click on "Edit", it shows correctly what I designed.
But the Checkbox doesn't automatically checked.
I mean when I edit a specific row, the checkbox of that row should be set to TRUE. Please attack the pics!
(This problem doesn't happen when EditMode="InPlace")
Thanks!
Andy.
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 09 Nov 2010, 05:51 AM
Hello Andy,
Try the following code snippet in ItemDataBound event to select the CheckBox in parent row of edit form .
C#:
Thanks,
Princy.
Try the following code snippet in ItemDataBound event to select the CheckBox in parent row of edit form .
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridEditFormItem && e.Item.IsInEditMode) { GridEditFormItem editItem = (GridEditFormItem)e.Item; GridDataItem item = (GridDataItem)editItem.ParentItem; // accessing parent row of edit form CheckBox chkbox = (CheckBox)item.FindControl("CheckBox1"); // access the CheckBox in parent row chkbox.Checked = true; } }Thanks,
Princy.
0
Andy
Top achievements
Rank 1
answered on 09 Nov 2010, 04:44 PM
Hi Princy!
I tried your code. But it can't find the the Checkbox.
Here is my code
ASPX
VB
Thanks!
Andy.
I tried your code. But it can't find the the Checkbox.
Here is my code
ASPX
<Columns><telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" /><telerik:GridButtonColumn ItemStyle-Width="200px" Text="Open" CommandName="Edit" UniqueName="AutoGeneratedEditColumn"></telerik:GridButtonColumn> <telerik:GridButtonColumn ItemStyle-Width="200px" Text="Close" CommandName="Delete" UniqueName="AutoGeneratedDeleteColumn"></telerik:GridButtonColumn> ...</Column>Protected Sub grdExceptionList_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdExceptionList.ItemDataBound If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then Dim editItem As GridEditFormItem = TryCast(e.Item, GridEditFormItem) Dim item As GridDataItem = TryCast(editItem.ParentItem, GridDataItem) Dim chkbox As CheckBox = TryCast(item.FindControl("ClientSelectColumn"), CheckBox) chkbox.Checked = True End If End SubThanks!
Andy.
0
Princy
Top achievements
Rank 2
answered on 10 Nov 2010, 07:26 AM
Hello Andy,
The Following code snippet shows how to get reference to the CheckBox in GridClientSelectColumn. But if you want to select the CheckBox, you need to select the row (which in turn select the CheckBox in GridClientSelectColumn).
VB.Net:
Thanks,
Princy.
The Following code snippet shows how to get reference to the CheckBox in GridClientSelectColumn. But if you want to select the CheckBox, you need to select the row (which in turn select the CheckBox in GridClientSelectColumn).
VB.Net:
Protected Sub grdExceptionLis_ItemDataBound(sender As Object, e As GridItemEventArgs) If TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode Then Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) Dim item As GridDataItem = DirectCast(editItem.ParentItem, GridDataItem) Dim chkbox As CheckBox = DirectCast(item("ClientSelectColumn").Controls(0), CheckBox) ' get reference to Checkbox ' select the row item.Selected = True End IfEnd SubThanks,
Princy.
0
Hello Andy,
This checkbox represents the client select column for the grid so you need to select the item that you are editing. This can be achieved in the following way: first we get the index of the item that is edited and then in the PreRender event we can manually select the item with this index. Here is a sample code illustrating this approach:
Let me know how this works for you and if you have any other questions.
Regards,
Marin
the Telerik team
This checkbox represents the client select column for the grid so you need to select the item that you are editing. This can be achieved in the following way: first we get the index of the item that is edited and then in the PreRender event we can manually select the item with this index. Here is a sample code illustrating this approach:
int itemIndex=-1; protected void RadGrid2_ItemDataBound(object sender, Web.UI.GridItemEventArgs e) { if (e.Item is Web.UI.GridEditableItem && e.Item.IsInEditMode) { itemIndex=e.Item.ItemIndex; } } protected override void OnPreRender(System.EventArgs e) { base.OnPreRender(e); if (itemIndex>=0) { RadGrid2.Items[itemIndex].Selected = true; } }Let me know how this works for you and if you have any other questions.
Regards,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy
Top achievements
Rank 1
answered on 10 Nov 2010, 04:51 PM
Thanks Princy and Martin!
It works correctly right now!
Andy.
It works correctly right now!
Andy.