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

Edited Item in PopUp Window

3 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Liam
Top achievements
Rank 1
Liam asked on 11 Feb 2009, 04:16 PM

I'm moving to using a PopUp template for the updating of records within a RadGrid, but am unable to retrieve the updated value from my text box, it keeps returning the original value.

Below I've included a very simple grid with just the one column and the same is happening.

<telerik:RadGrid ID="rgTestData" runat="server" AutoGenerateColumns="False" GridLines="None" 
        Skin="WebBlue" Width="600px" OnInsertCommand="rgTestData_InsertCommand" OnCancelCommand="rgTestData_CancelCommand" 
        OnUpdateCommand="rgTestData_UpdateCommand" AllowPaging="True" AutoGenerateEditColumn="True" 
        OnItemCommand="rgTestData_ItemCommand">  
        <HeaderContextMenu> 
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </HeaderContextMenu> 
        <MasterTableView CommandItemDisplay="TopAndBottom" EditMode="PopUp">  
            <RowIndicatorColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </RowIndicatorColumn> 
            <ExpandCollapseColumn> 
                <HeaderStyle Width="20px"></HeaderStyle> 
            </ExpandCollapseColumn> 
            <Columns> 
                <telerik:GridBoundColumn DataField="genericName" HeaderText="Generic Name" UniqueName="genericName">  
                </telerik:GridBoundColumn> 
            </Columns> 
            <EditFormSettings EditFormType="Template">  
                <EditColumn AutoPostBackOnFilter="True" UniqueName="EditCommandColumn1">  
                </EditColumn> 
                <FormTemplate> 
                    <telerik:RadTextBox ID="txtGenericName" runat="server" Skin="WebBlue" Width="125px" 
                        Text='<%# Bind("genericName") %>'>  
                    </telerik:RadTextBox> 
                    <br /> 
                    <asp:LinkButton ID="btnSave" runat="server" Text="Save" CommandName="Update" /> 
                    <asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" /> 
                </FormTemplate> 
            </EditFormSettings> 
        </MasterTableView> 
        <FilterMenu> 
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </FilterMenu> 
    </telerik:RadGrid> 

I'm then very simply trying to pull back the new value I've entered in the textbox after the Update button is pressed.

protected void rgTestData_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
        {  
            if (e.CommandName == RadGrid.UpdateCommandName)  
            {  
                if (e.Item is GridEditFormItem && e.Item.IsInEditMode)  
                {  
                    GridEditableItem item = e.Item as GridEditableItem;  
 
                    String GenericName = item["genericName"].Text.ToString();  
                }  
            }
        } 

Thanks in advance for any help provided in resolving my problem.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Feb 2009, 04:24 AM
Hi,

Try out the following code snippet.

CS:
protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) 
    { 
        GridEditFormItem editformItem = (GridEditFormItem)e.Item; 
        RadTextBox txtbx = (RadTextBox)editformItem.FindControl("txtGenericName"); 
        string strTxt = txtbx.Text; 
 
    } 


Thanks
Shinu




0
Liam
Top achievements
Rank 1
answered on 12 Feb 2009, 08:46 AM
Unfortunately that did not work either, the same is happening.

I'm wondering if I've created the grid wrongly, but all has been developed through the builder (no hand coding), so I'd hope it is all as it should be.

Thanks.
0
Liam
Top achievements
Rank 1
answered on 12 Feb 2009, 10:29 AM
I have found a work around.

Originally I had been pulling the data from a business object which was called from the page and manually binding this to the grid. I have now dropped an Object Scope Provider control on to the page and pulling the data from here.

This solution isn't ideal for me, so if anyone could offer any tips they'd be greatly appreciated!

Once again thanks.
Tags
Grid
Asked by
Liam
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Liam
Top achievements
Rank 1
Share this question
or