<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<telerik:RadButton
ID
=
"btnIcon"
runat
=
"server"
OnClick
=
"btn_Click"
OnClientClicking
=
"OnClientClicking"
Text
="Start"
</
telerik:RadButton
>
</
FormTemplate
>
</
EditFormSettings
>
Hi,
Above only example which releated to my scenario.
I have RadButton in <EditFormSettings> . I tried to find control using FinControl in Item_DataBound by following code and disable RadButton.
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = (GridEditableItem)e.Item;
RadButton btnStart
= (FileUpload)item.FindControl(
"btnStart"
);
btnStart.Enabled = false;
}
when i debug even it is not entering (if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
) . I think i am missing some thing.
Could you please let me know , how to find control in code behind and disable control.
Thanks,
Ravikiran
4 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 19 Nov 2013, 03:55 AM
Hi Ravi,
The control will go inside the for-loop only when the RadGrid is in EditMode. Make sure you access the control when in edit mode. Please try the below code snippet to access the RadButton inside EditFormSettings.
ASPX:
C#:
Thanks,
Princy
The control will go inside the for-loop only when the RadGrid is in EditMode. Make sure you access the control when in edit mode. Please try the below code snippet to access the RadButton inside EditFormSettings.
ASPX:
<
telerik:RadButton
ID
=
"btnIcon"
runat
=
"server"
Text
=
"Start"
. . . . >
</
telerik:RadButton
>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem edit = (GridEditFormItem)e.Item;
RadButton btnStart = (RadButton)edit.FindControl(
"btnIcon"
);
btnStart.Enabled =
false
;
}
}
Thanks,
Princy
0

Ravi
Top achievements
Rank 1
answered on 19 Nov 2013, 11:35 AM
Hi Princy,
Thanks for reply.
here the above code ...in aspx. but i tried with code which you gave me. It is not entering in below if condition.
Can you please let me know what i am missing here in apsx.
Thanks,
Ravikiran
Thanks for reply.
<
telerik:RadGrid ID="RadGridEntity" runat="server" BorderColor="Black" AllowSorting="True"
CellSpacing="0" CellPadding="0" Skin="Outlook" AutoGenerateColumns="False" Width="100%"
ItemStyle-Font-Names="Verdana" ItemStyle-Font-Size="Small" AlternatingItemStyle-Font-Names="Verdana"
AlternatingItemStyle-Font-Size="Small" HeaderStyle-Font-Names="Verdana" HeaderStyle-Font-Size="Small"
HeaderStyle-Font-Bold="true" ItemStyle-HorizontalAlign="Left" AlternatingItemStyle-HorizontalAlign="Left"
GroupHeaderItemStyle-HorizontalAlign="Left" ShowStatusBar="True" OnPreRender="RadGridEntity_PreRender"
OnNeedDataSource="RadGridEntity_NeedDataSource" OnInsertCommand="AddStandardActivities"
OnUpdateCommand="UpdateStopActivity" OnDeleteCommand="DeleteStandardActivities"
OnCancelCommand="RadGridEntity_CancelCommand" OnItemDataBound="RadGridEntity_ItemDataBound"
OnItemUpdated="RadGridEntity_ItemUpdated" ShowFooter="true">
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Outlook">
<
EditFormSettings InsertCaption="Add new item" EditFormType="Template">
<FormTemplate>
<table id="Table1" width="100%" cellspacing="0" cellpadding="0" border="0" class="editFormTemplate">
<tr class="OWTFont-common">
<td>
Standard Activity List:
</td>
</tr>
<tr>
<td>
<asp:DataList ID="StandardActivitiesDataList" runat="server" RepeatDirection="Horizontal"
Width="100%" RepeatColumns="5" DataSource='<%#dt%>' DataMember="StandardActivityTable">
<ItemTemplate>
<asp:CheckBox ID="chkTimeSheetActivity" runat="server" Text='<%# Eval("Name") %>'
CssClass="OWTFont-common" />
<asp:Label ID="lblTSActivityID" runat="server" Text='<%# Eval("ActivityID") %>'
Visible="false" CssClass="OWTFont-common"></asp:Label>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="editFormTemplate">
<tr>
<td align="right" colspan="2" style="height: 25px">
<table cellspacing="0" cellpadding="0">
<tr>
<td>
<telerik:RadButton ID="btnStart" runat="server" Skin="Forest" Font-Names="Verdana"
Font-Size="Small" Text='Start' CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</telerik:RadButton>
</td>
<td>
<telerik:RadButton ID="BtnSave" runat="server" Skin="Forest" Font-Names="Verdana"
Font-Size="Small" Text='<%# (Container is GridEditFormInsertItem) ? "Add Standard Activity" : "Update" %>'
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'
OnClientClicking="SaveConfirmation">
</telerik:RadButton>
</td>
<td>
<telerik:RadButton ID="BtnCancel" runat="server" Skin="Forest" Font-Names="Verdana"
Font-Size="Small" Text="Cancel" CausesValidation="False" CommandName="Cancel">
</telerik:RadButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
here the above code ...in aspx. but i tried with code which you gave me. It is not entering in below if condition.
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode).. and unbale to find Rad button ("btnStart")..
Here i am Inseting using "AddStandared Activity" button of checking checkboxes which are binded. <EditFormSettings>.
Need to set any EditMode property of <EditFormSettings> in aspx or in Codebehind while binding RadGrid?.
Can you please let me know what i am missing here in apsx.
Thanks,
Ravikiran
0

Princy
Top achievements
Rank 2
answered on 20 Nov 2013, 05:08 AM
Hi Ravi,
Unfortunately, i couldn't replicate the issue. The code works fine at my end. When the RadGrid is in EditMode it will enter the loop " if (e.Item is GridEditFormItem && e.Item.IsInEditMode)". Below is a sample code that i tried to access a RadButton in editform. If this doesn't help, please provide your full code snippet and elaborate about requirement.
ASPX:
C#:
Thanks,
Princy
Unfortunately, i couldn't replicate the issue. The code works fine at my end. When the RadGrid is in EditMode it will enter the loop " if (e.Item is GridEditFormItem && e.Item.IsInEditMode)". Below is a sample code that i tried to access a RadButton in editform. If this doesn't help, please provide your full code snippet and elaborate about requirement.
ASPX:
<
telerik:RadGrid
ID
=
"RadGridEntity"
runat
=
"server"
AutoGenerateColumns
=
"true"
AutoGenerateEditColumn
=
"true"
DataSourceID
=
"SqlDataSource1"
OnItemDataBound
=
"RadGridEntity_ItemDataBound"
>
<
MasterTableView
CommandItemDisplay
=
"Top"
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
table
id
=
"Table1"
>
<
tr
>
<
td
>
Customer ID:
</
td
>
</
tr
>
<
tr
>
<
td
>
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
></
asp:TextBox
>
</
td
>
</
tr
>
</
table
>
<
table
>
<
tr
>
<
td
>
<
telerik:RadButton
ID
=
"btnStart"
runat
=
"server"
Text
=
'Start'
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</
telerik:RadButton
>
</
td
>
<
td
>
<
telerik:RadButton
ID
=
"BtnSave"
runat
=
"server"
Text='<%# (Container is GridEditFormInsertItem) ? "Add Customer" : "Update" %>'
CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</
telerik:RadButton
>
</
td
>
<
td
>
<
telerik:RadButton
ID
=
"BtnCancel"
runat
=
"server"
Text
=
"Cancel"
CommandName
=
"Cancel"
>
</
telerik:RadButton
>
</
td
>
</
tr
>
</
table
>
</
FormTemplate
>
</
EditFormSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGridEntity_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormItem && e.Item.IsInEditMode)
{
GridEditFormItem edit = (GridEditFormItem)e.Item;
RadButton btnStart = (RadButton)edit.FindControl(
"btnStart"
);
btnStart.Enabled =
false
;
}
}
Thanks,
Princy
0

Ravi
Top achievements
Rank 1
answered on 20 Nov 2013, 12:33 PM
Hi Princy,
Thanks a lot. I found the issue from which you provide me with example. Thanks once again.
Thanks
Ravikiran
Thanks a lot. I found the issue from which you provide me with example. Thanks once again.
Thanks
Ravikiran