I have a RadDataForm:
<telerik:RadDataForm runat="server" ID="RadDataForm1"
DataKeyNames="IdCompra"
DataSourceID="dsCompraDivisasEncabezado"
Skin="Windows7"
OnDataBound="RadDataForm1_DataBound"
OnItemInserting="RadDataForm1_ItemInserting"
>
<EditItemTemplate>
<fieldset class="rdfFieldset rdfBorders" style="width:550px;">
<legend class="rdfLegend">Compra de Divisas</legend>
<div class="rdfRow">
<asp:Label ID="lblIdCompania" runat="server" CssClass="rdfLabel rdfBlock" Text="Id CompaƱia:"></asp:Label>
<telerik:RadComboBox runat="server" ID="rcbCompania"
DataSourceID="dsCompanias"
DataTextField="CompaniaDescripcion"
DataValueField="IdCompania"
AutoPostBack="true"
OnSelectedIndexChanged="rcbCompania_SelectedIndexChanged">
</telerik:RadComboBox>
</div>
<div class="rdfRow">
<asp:Label ID="lblIdPlanta" runat="server" CssClass="rdfLabel rdfBlock" Text="Planta:"></asp:Label>
<asp:Label ID="lblIdPlantaValor" runat="server" CssClass="rdfFieldValue" Text='<%# String.Concat(Eval("IdPlanta"), " - ",Eval("PlantaDescripcion"))%>' />
</div>
</fieldset>
</EditItemTemplate>
<InsertItemTemplate>
<fieldset class="rdfFieldset rdfBorders" style="width:550px;">
<legend class="rdfLegend">Compra de Divisas</legend>
<div class="rdfRow">
<asp:Label ID="lblIdCompania" runat="server" CssClass="rdfLabel rdfBlock" Text="Id CompaƱia:"></asp:Label>
<telerik:RadComboBox runat="server" ID="rcbCompania"
DataSourceID="dsCompanias"
DataTextField="CompaniaDescripcion"
DataValueField="IdCompania"
AutoPostBack="true"
OnSelectedIndexChanged="rcbCompania_SelectedIndexChanged">
</telerik:RadComboBox>
</div>
<div class="rdfRow">
<asp:Label ID="lblIdPlanta" runat="server" CssClass="rdfLabel rdfBlock" Text="Planta:"></asp:Label>
<asp:Label ID="lblIdPlantaValor" runat="server" CssClass="rdfFieldValue" Text='<%# String.Concat(Eval("IdPlanta"), " - ",Eval("PlantaDescripcion"))%>' />
</div>
</fieldset>
</InsertItemTemplate>
The next procedure works when RadDataForm is in edit mode:
protected void rcbCompania_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox rcbCompania = (RadComboBox)sender;
Label lblIdPlantaValor = (Label)RadDataForm1.Items[0].FindControl("lblIdPlantaValor");
string strMensaje = "";
DataTable dtCompania = CompaniaConsulta("Divisas", "ID", rcbCompania.SelectedValue, out strMensaje);
lblIdPlantaValor.Text = dtCompania.Rows[0]["IdPlanta"].ToString() + "-" + dtCompania.Rows[0]["PlantaDescripcion"].ToString();
} but when it is in Insert mode it says: RadDataForm1.Items.Count = 0. How can i find the control?
<telerik:RadDataForm runat="server" ID="RadDataForm1"
DataKeyNames="IdCompra"
DataSourceID="dsCompraDivisasEncabezado"
Skin="Windows7"
OnDataBound="RadDataForm1_DataBound"
OnItemInserting="RadDataForm1_ItemInserting"
>
<EditItemTemplate>
<fieldset class="rdfFieldset rdfBorders" style="width:550px;">
<legend class="rdfLegend">Compra de Divisas</legend>
<div class="rdfRow">
<asp:Label ID="lblIdCompania" runat="server" CssClass="rdfLabel rdfBlock" Text="Id CompaƱia:"></asp:Label>
<telerik:RadComboBox runat="server" ID="rcbCompania"
DataSourceID="dsCompanias"
DataTextField="CompaniaDescripcion"
DataValueField="IdCompania"
AutoPostBack="true"
OnSelectedIndexChanged="rcbCompania_SelectedIndexChanged">
</telerik:RadComboBox>
</div>
<div class="rdfRow">
<asp:Label ID="lblIdPlanta" runat="server" CssClass="rdfLabel rdfBlock" Text="Planta:"></asp:Label>
<asp:Label ID="lblIdPlantaValor" runat="server" CssClass="rdfFieldValue" Text='<%# String.Concat(Eval("IdPlanta"), " - ",Eval("PlantaDescripcion"))%>' />
</div>
</fieldset>
</EditItemTemplate>
<InsertItemTemplate>
<fieldset class="rdfFieldset rdfBorders" style="width:550px;">
<legend class="rdfLegend">Compra de Divisas</legend>
<div class="rdfRow">
<asp:Label ID="lblIdCompania" runat="server" CssClass="rdfLabel rdfBlock" Text="Id CompaƱia:"></asp:Label>
<telerik:RadComboBox runat="server" ID="rcbCompania"
DataSourceID="dsCompanias"
DataTextField="CompaniaDescripcion"
DataValueField="IdCompania"
AutoPostBack="true"
OnSelectedIndexChanged="rcbCompania_SelectedIndexChanged">
</telerik:RadComboBox>
</div>
<div class="rdfRow">
<asp:Label ID="lblIdPlanta" runat="server" CssClass="rdfLabel rdfBlock" Text="Planta:"></asp:Label>
<asp:Label ID="lblIdPlantaValor" runat="server" CssClass="rdfFieldValue" Text='<%# String.Concat(Eval("IdPlanta"), " - ",Eval("PlantaDescripcion"))%>' />
</div>
</fieldset>
</InsertItemTemplate>
The next procedure works when RadDataForm is in edit mode:
protected void rcbCompania_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox rcbCompania = (RadComboBox)sender;
Label lblIdPlantaValor = (Label)RadDataForm1.Items[0].FindControl("lblIdPlantaValor");
string strMensaje = "";
DataTable dtCompania = CompaniaConsulta("Divisas", "ID", rcbCompania.SelectedValue, out strMensaje);
lblIdPlantaValor.Text = dtCompania.Rows[0]["IdPlanta"].ToString() + "-" + dtCompania.Rows[0]["PlantaDescripcion"].ToString();
} but when it is in Insert mode it says: RadDataForm1.Items.Count = 0. How can i find the control?