This is a migrated thread and some comments may be shown as answers.

not recognize newValue of GridTemplateColumn

4 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Santos
Top achievements
Rank 1
Santos asked on 06 Feb 2013, 08:54 AM
I have the next code:

<telerik:GridTemplateColumn 
                        HeaderText="<%$ Resources:Nervia.Plus.Axon, NUMERO_SERIE %>" 
                        UniqueName="NUMEROSERIE" 
                        AllowFiltering="True"
                        >
                        <ItemTemplate>
                        <%# Eval("Articulos.NUMEROSERIE")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <telerik:RadComboBox 
                                ID="rcbNumeroSerie" 
                                runat="server" 
                                Width="130px"
                                DropDownWidth="560px" 
                                ShowMoreResultsBox="True" 
                                EnableVirtualScrolling="True"
                                Filter="Contains">
                                <HeaderTemplate>
                                    <table style="width: 360px" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td style="width: 110px;"> <asp:Label ID="lbl1" runat="server" Text="<%$ Resources:Nervia.Plus.Axon, MARCA %>" Font-Bold="True"></asp:Label></td>
                                            <td style="width: 200px;"> <asp:Label ID="lbl2" runat="server" Text="<%$ Resources:Nervia.Plus.Axon, MODELO %>" Font-Bold="True"></asp:Label></td>
                                            <td style="width: 200px;"> <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Nervia.Plus.Axon, NUMERO_SERIE %>" Font-Bold="True"></asp:Label></td>
                                        </tr>
                                    </table>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <table style="width: 360px" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td style="width: 100px;">
                                                <%# DataBinder.Eval(Container, "Attributes['MARCA']")%>
                                            </td>
                                            <td style="width: 200px;">
                                                <%# DataBinder.Eval(Container, "Attributes['MODELO']")%>
                                            </td>
                                            <td style="width: 200px;">
                                                <%# DataBinder.Eval(Container, "Text")%>
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </telerik:RadComboBox>
                        </EditItemTemplate>
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="140px" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="140px" />
                    </telerik:GridTemplateColumn>

the values of radcombobox it's loaded in the server but when i enter in insert mode and load the newValues, numeroSerie don't show in the array, even newValues["NUMEROSERIE"] = null :S

thanks for your helps and sorry for my english.

4 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 11 Feb 2013, 07:31 AM
Hello Jorge,

The provided information is not enough to pinpoint the reason for that behavior. Could you please send us your code behind as well? Additionally you could check out the following live example.

Greetings,
Kostadin
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
Santos
Top achievements
Rank 1
answered on 11 Feb 2013, 08:04 AM
Hello kostadin: 

The event ItemCreated:

protected void rgVisorDispositivos_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item is GridDataInsertItem)
            {
                GridEditableItem editItem = (GridEditableItem)e.Item;
                RadComboBox combo = (RadComboBox)editItem["NUMEROSERIE"].Controls[1];

                combo.Items.Clear();
                ArticulosManager AManager = new ArticulosManager();
                List<Articulos> lista = AManager.ObtenerTodosFilteredNumSerieTipo8T13(); 

                foreach (Articulos art in lista)
                {
                    RadComboBoxItem Item = new RadComboBoxItem();
                    Item.Value = art.NUMEROSERIE;
                    Item.Text = art.NUMEROSERIE;
                    Item.Attributes.Add("MARCA", art.MARCA);
                    Item.Attributes.Add("MODELO", art.MODELO);
                    combo.Items.Add(Item);
                    Item.DataBind();
                }
            }
        }

protected void rgVisorDispositivos_UpdateCommand(object sender, GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            Hashtable newValues = new Hashtable();
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);

}

the problem is that the values ​​of "newValues" not found "NUMEROSERIE"



I need a provisional solution, how I can pass the value using JavaScript to GridBoundColumn?

Tanks.
0
Accepted
Shinu
Top achievements
Rank 2
answered on 11 Feb 2013, 08:35 AM
Hi,

If you have a GridTemplateColumn with a custom EditItemTemplate and controls you are creating inside it, you cannot use the ExtractValuesFromItem() method, as this method works only for auto-generated column editors. You will need to find the controls inside your EditItemTemplate and reference them by ID as follows.

C#:
protected void rgVisorDispositivos_UpdateCommand(object sender, GridCommandEventArgs e)
{
      GridEditableItem editedItem = e.Item as GridEditableItem;
      RadComboBox combo = (RadComboBox)editedItem.FindControl("rcbNumeroSerie"); //access the combobox here
}

Thanks,
Shinu.


0
Santos
Top achievements
Rank 1
answered on 11 Feb 2013, 09:03 AM
Perfect Shinu, this is the solution.
Tags
Grid
Asked by
Santos
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Santos
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or