Hi,
I have a page that contains a grid. The grid contains a formtemplate for use when editing an item in the grid. Inside the formtemplate I have an aspplaceholder control that will be populated with a table that contains other controls. I am able to get the controls to populate in the place holder and to also populate with data. When the update command event is fired and I try to pull the values from the placeholder control the placeholder states it contains no controls. Here is a sample of the aspx page code I am using and the C# code that is used in the update command event.
I have placed the code to populate the placeholder control in the itemcreated and the itemdatabound methods of the datagrid, but it still loses its controls when using the updatecommand.
Thanks
I have a page that contains a grid. The grid contains a formtemplate for use when editing an item in the grid. Inside the formtemplate I have an aspplaceholder control that will be populated with a table that contains other controls. I am able to get the controls to populate in the place holder and to also populate with data. When the update command event is fired and I try to pull the values from the placeholder control the placeholder states it contains no controls. Here is a sample of the aspx page code I am using and the C# code that is used in the update command event.
<div>
<asp:PlaceHolder id="phEdit" runat="server" />
</div>
if
(((PlaceHolder)e.Item.FindControl("phEdit")).Controls.Count>0)
I have placed the code to populate the placeholder control in the itemcreated and the itemdatabound methods of the datagrid, but it still loses its controls when using the updatecommand.
Thanks
7 Answers, 1 is accepted
0
TsvetoslavHello Jonathan,
The correct way to extract the values from the edit form controls is through the ExtractValues() methods of the edit form item that's contained within the UpdateCommand event args object:
Hashtable newValues = new Hashtable();
((GridEditableItem)e.Item).ExtractValues(newValues);
Of course, the above-mentioned approach supposes that you have binding expressions for the controls in the edit form.
Hope it helps.
Regards,
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

Tommy
Top achievements
Rank 1
answered on 30 Aug 2012, 03:32 PM
Hi ,
I have the same situation here. I have a grid FormTemplate with a placeholder in it. I create a couple of RadDateInput dynamically on selectedindex changed event from a radcombobox in the template. I can't retreive values in it on UpdateCommand. There are allways empty.
I tried
Dim eItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim phHoraire = DirectCast(eItem.FindControl("phHoraire"), PlaceHolder)
CType(phHoraire.FindControl("edHeure1"), RadDateInput).Text
or
CType(eitem.FindControl("edHeure1"), RadDateInput).Text
and nothing works
.
here is the code of the Combobox IndexChanged event :
I have the same situation here. I have a grid FormTemplate with a placeholder in it. I create a couple of RadDateInput dynamically on selectedindex changed event from a radcombobox in the template. I can't retreive values in it on UpdateCommand. There are allways empty.
I tried
Dim eItem As GridEditableItem = CType(e.Item, GridEditableItem)
Dim phHoraire = DirectCast(eItem.FindControl("phHoraire"), PlaceHolder)
CType(phHoraire.FindControl("edHeure1"), RadDateInput).Text
or
CType(eitem.FindControl("edHeure1"), RadDateInput).Text
and nothing works
<
telerik:RadComboBox
ID
=
"cboFrequence"
runat
=
"server"
Width
=
"70px"
Height
=
"200px"
AllowCustomText
=
"true"
MarkFirstMatch
=
"True"
EnableLoadOnDemand
=
"false"
DataTextField
=
"PPSO_CODE"
DataValueField
=
"PPSO_NOAUTO"
ItemsPerRequest
=
"10"
DropDownWidth
=
"400px"
EnableVirtualScrolling
=
"true"
ShowMoreResultsBox
=
"false"
HighlightTemplatedItems
=
"True"
OnInit
=
"cboFrequence_Load"
OnClientBlur
=
"cboForceSelection"
OnSelectedIndexChanged
=
"cboFrequence_SelectedIndexChanged"
OnItemsRequested
=
"cboFrequenceItemRequested"
OnClientSelectedIndexChanged
=
"cboFrequenceIndexChanged"
OnClientLoad
=
"affichageDuree"
>
</
telerik:RadComboBox
>
<
asp:PlaceHolder
runat
=
"server"
ID
=
"phHoraire"
></
asp:PlaceHolder
>
here is the code of the Combobox IndexChanged event :
Protected Sub cboFrequence_SelectedIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
If Not String.IsNullOrEmpty(e.Value) Then
Dim multi As Integer = 0
Dim cbo = DirectCast(sender, RadComboBox)
Dim phHoraire = cbo.NamingContainer.FindControl("phHoraire")
Dim tmpSQL As LWebStatement = ExecuteSql("Select ppso_multiplic from PHFPRESCRIPTEUR_POSO" & _
" where ppso_noauto = " & GetStr(e.Value))
Dim ctrlfocus As Control = cbo.NamingContainer.FindControl("edDuree")
phHoraire.Controls.Clear()
If tmpSQL.HasRecord Then
multi = StrToIntDef(tmpSQL.GetString("PPSO_MULTIPLIC"), 0)
For i = 1 To multi Step 1
Dim txtDate As New RadDateInput()
txtDate.DateFormat = "HH:mm"
txtDate.Width = New Unit(42, UnitType.Pixel)
txtDate.ID = "edHeure" & i.ToString
txtDate.Attributes.Add("style", "margin: 0px 5px 0px 5px;")
txtDate.Attributes.Add("runat", "server")
phHoraire.Controls.Add(txtDate)
If i = 1 Then
ctrlfocus = txtDate
End If
Next
End If
cbo.NamingContainer.FindControl("DivHoraire").Visible = multi <> 0
RadAjaxManager1.FocusControl(ctrlfocus)
End If
End Sub
0
Hi Tommy,
Did you try the approach I mentioned in my previous post:
Regards,
Tsvetoslav
the Telerik team
Did you try the approach I mentioned in my previous post:
Hashtable newValues =
new
Hashtable();
((GridEditableItem)e.Item).ExtractValues(newValues);
Regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Tommy
Top achievements
Rank 1
answered on 04 Sep 2012, 12:37 PM
Hello,
the
Thanks
the
ExtractValues
method only retreive data with then <%# Bind("Something") %> attribute within aspx code. Is there a way to call the Bind function on server side code to bind my newly created controls on custom attributes?Thanks
0
Hello Tommy,
Unfortunately, what you are trying to achieve is not a trivial task.
1. First of all you have to create the edit form dynamically using the IBindableTemplate.
2. This, for its part, entails that the whole grid has to be created programmatically in the Page_Init event.
3. Then you have to create the dynamic date input controls in the SelectedIndexChanged event of the combo, set a flag somewhere and recreate those controls with the same ID's in the InstantiateIn method of the IBindableTemplate conditionally - if the above-mentioned flag is set.
I have prepared a small sample that demonstrates this approach.
Hope it helps.
Regards,
Tsvetoslav
the Telerik team
Unfortunately, what you are trying to achieve is not a trivial task.
1. First of all you have to create the edit form dynamically using the IBindableTemplate.
2. This, for its part, entails that the whole grid has to be created programmatically in the Page_Init event.
3. Then you have to create the dynamic date input controls in the SelectedIndexChanged event of the combo, set a flag somewhere and recreate those controls with the same ID's in the InstantiateIn method of the IBindableTemplate conditionally - if the above-mentioned flag is set.
I have prepared a small sample that demonstrates this approach.
Hope it helps.
Regards,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0

Tommy
Top achievements
Rank 1
answered on 06 Sep 2012, 02:20 PM
Hello Tsvetoslav,
thanks for the reply. Does the grid itself absolutely has to be created dynamically? Is there a way to just recreate my RadDateInput in my template on page_init event?
thanks
thanks for the reply. Does the grid itself absolutely has to be created dynamically? Is there a way to just recreate my RadDateInput in my template on page_init event?
thanks
0
Hi Tommy,
That's all right in most cases - just assign the template in the Page_Init event:
All the best,
Tsvetoslav
the Telerik team
That's all right in most cases - just assign the template in the Page_Init event:
protected
void
Page_Init(
object
sender, EventArgs e)
{
RadGrid1.MasterTableView.EditFormSettings.EditFormType = GridEditFormType.Template;
RadGrid1.MasterTableView.EditFormSettings.FormTemplate =
new
MyEditFormTemplate();
}
All the best,
Tsvetoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.