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

In Place editing loses field values in edit mode

1 Answer 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vithiya
Top achievements
Rank 1
Vithiya asked on 16 Apr 2009, 09:03 PM
I have a small grid with just two columns, Id and User. I have changed the grid's look and feel so that the Add can be done through a seperate button and it works. The grid has two editcolumns Edit and Delete. Delete works fine too. Clicking the edit button brings up the inplace edit boxes, but they are blank. Why am I missing those values? Here is my code for the grid definition and teh code behind for it.

The datasource is a datatable with three columns Id, User and Type.

<telerik:RadGrid ID="grdUsers" runat="server" runat="server" AllowAutomaticUpdates="True" ShowHeader="False"
                OnNeedDataSource="grdUsers_NeedDataSource" OnPreRender="grdUsers_PreRender"
                AutoGenerateColumns="False" GridLines="None"
                Height="100px" Width="400px" OnItemCommand="grdUsers_ItemCommand" SkinID="WithBorder">
                 <HeaderContextMenu EnableTheming="True">
                    <CollapseAnimation Duration="200" Type="OutQuint" />
                </HeaderContextMenu>
                <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="Id" EditMode="InPlace">
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px" />
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px" />
                    </ExpandCollapseColumn>
                    <Columns>
                        <telerik:GridEditCommandColumn ButtonType="ImageButton"
                            HeaderStyle-Width="30px" UniqueName="EditCommandColumn">
                        </telerik:GridEditCommandColumn>
                        <telerik:GridBoundColumn DataField="Id" UniqueName="Id" Visible="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="User" UniqueName="User">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete"
                            ConfirmDialogType="RadWindow" ConfirmText="Delete this entry?"
                            ConfirmTitle="Delete" HeaderStyle-Width="50px" Text="Delete"
                            UniqueName="DeleteColumn">
<HeaderStyle Width="50px"></HeaderStyle>

                            <ItemStyle CssClass="" HorizontalAlign="Center" />
                        </telerik:GridButtonColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings>
                    <Scrolling AllowScroll="True" />
                </ClientSettings>
                <FilterMenu EnableTheming="True">
                    <CollapseAnimation Duration="200" Type="OutQuint" />
                </FilterMenu>
            </telerik:RadGrid>

protected void grdUsers_ItemCommand(object source, GridCommandEventArgs e)
        {
            GridEditableItem editItem;
            switch (e.CommandName)
            {
                case (RadGrid.DeleteCommandName):
                    editItem = e.Item as GridEditableItem;
                    DeleteItem(editItem);
                    grdUsers.Rebind();
                case RadGrid.UpdateCommandName:
                    if (e.Item is GridEditableItem)
                    {
                        editItem = e.Item as GridEditableItem;
                        UpdateItem(editItem);
                        grdUsers.Rebind();
                    }
                    break;
            }
        }

        protected void grdUsers_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            if (ViewState["dTable"] != null)
            {
                dTable = (DataTable)ViewState["dTable"];
                grdUsers.DataSource = dTable;
            }
        }
Thanks,
Vithiya





1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 22 Apr 2009, 06:25 AM
Hello Vithiya,

I do not see any specific reason for loosing values when attempt to edit.
However I noticed that you have attached handler to RadGrid.PreRender event. Please ensure that you are not performing some action that might cause loosing this values, i.e Rebind or something else.

I will also suggest you to not keep data source(DataTable object ViewState["dTable"] ) in ViewState.

Best wishes,
Nikolay
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Vithiya
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or