If i use RadGrid in this way (http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/templateformupdate/defaultcs.aspx), and if inside that FormTemplateEditForm i have another RadGrid, how can i "find" it? If I use (RadGrid)this.Master.FindControl("RadGrid2") i get a null value.
How cand i acces some controls in TemplateEditForm? How can i "find" them?
How cand i acces some controls in TemplateEditForm? How can i "find" them?
6 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 18 Jun 2012, 09:36 AM
Hi Catalina,
Try the following code to access controls inside FormTemplate.
C#:
Thanks,
Shinu.
Try the following code to access controls inside FormTemplate.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item.IsInEditMode && e.Item
is
GridEditFormItem)
{
GridEditFormItem editForm = (GridEditFormItem)e.Item;
RadGrid grid = (RadGrid)editForm.FindControl(
"RadGrid2"
);
}
}
Thanks,
Shinu.
0
Catalina
Top achievements
Rank 1
answered on 18 Jun 2012, 10:51 AM
Yes, this works. But, for example, if in "
RadGrid1_UpdateComand
", i want to acces some controls inside FormTemplate (my RadGrid2 or anything ele) how can i do that?0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 18 Jun 2012, 11:03 AM
Hello catalina,
Thanks,
Jayesh Goyani
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditFormItem editForm = (GridEditFormItem)e.Item;
RadGrid grid = (RadGrid)editForm.FindControl(
"RadGrid2"
);
}
Thanks,
Jayesh Goyani
0
Catalina
Top achievements
Rank 1
answered on 18 Jun 2012, 12:01 PM
One more question:
I want to access controls inside FormTemplate from page_load, or something like this ... is this possible?
I want to access controls inside FormTemplate from page_load, or something like this ... is this possible?
0
bharath
Top achievements
Rank 1
answered on 12 Jun 2015, 02:54 PM
Hi Jayesh
i want assign value to control which is inside grideditformitem on radgrid_editcommand event.
for example textbox inside the grideditformitem on click edit link in the grid i want to assign some value to textbox text property.
/Regards
Bharath.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 16 Jun 2015, 06:21 PM
Hello,
Please try with the below code snippet.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"false"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Name"
UniqueName
=
"Name"
></
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
></
telerik:GridEditCommandColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
asp:TextBox
ID
=
"txtID"
runat
=
"server"
Text='<%# Eval("ID") %>'></
asp:TextBox
>
<
asp:TextBox
ID
=
"txtName"
runat
=
"server"
></
asp:TextBox
>
</
FormTemplate
>
</
EditFormSettings
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
dynamic data =
new
[] {
new
{ ID = 1, Name =
"Name1"
},
new
{ ID = 2, Name =
"Name2"
}
};
RadGrid1.DataSource = data;
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item.IsInEditMode && e.Item
is
GridEditFormItem)
{
GridEditFormItem editForm = (GridEditFormItem)e.Item;
TextBox txtName = (TextBox)editForm.FindControl(
"txtName"
);
txtName.Text =
"jayesh"
;
}
}
Let me know if any concern.
Thanks,
Jayesh Goyani