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

Page Index Problem after Insert record

5 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gajanan
Top achievements
Rank 2
Gajanan asked on 24 Aug 2010, 08:12 AM
hello, every one

in my application i set the paging 30 for RadGrid
and on Insert command of Radgrid i am Inserting New record in database but problem is that after inserting the record
focus is going to the last page of Radgrid, even i am not setting the page Index in my code then also i am facing this problem.

plz tell the solution

5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 24 Aug 2010, 11:37 AM
Hi Gajanan ,

This is actually the default behavior of RadGrid control. However you should use TableView's InsertItemPageIndexAction property to modify it to better match your requirements.

Regards,
Rosen
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
Gajanan
Top achievements
Rank 2
answered on 24 Aug 2010, 01:18 PM
hi thank you for your replay , i tried what u said to me but it is not solving my problem even i used InsertItemPageIndexAction this property it is showing in red underline
 <radg:radgrid id="RadGrid_Orders" runat="server"
                           OnDeleteCommand="RadGrid_Orders_DeleteCommand"
                           OnItemCommand="RadGrid_Orders_ItemCommand"
                           OnNeedDataSource="RadGrid_Orders_NeedDataSource"
                           OnUpdateCommand="RadGrid_Orders_UpdateCommand"
                           OnInsertCommand="RadGrid_Orders_InsertCommand"
                           OnCancelCommand="RadGrid_Orders_CancelCommand"               
                           OnItemCreated ="RadGrid_Orders_ItemCreated"
                           OnItemDataBound ="RadGrid_Orders_OnItemDataBound"
                           OnPreRender="RadGrid_Orders_PreRender"               
                           DataMember="Orders" Width="100%" AllowPaging="true"
                           PageSize="30" PagerStyle-AlwaysVisible="true">
                <MasterTableView  AutoGenerateColumns="False" DataKeyNames="OrderId" DataMember="Orders"
                            CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnFirstPage">
  <EditFormSettings EditFormType="Template">
                        <FormTemplate>
                            <asp:Table ID="Table_SalesOrderEditorForm" Width="850px" runat="server">
                                <asp:TableRow Visible="false">
                                    <asp:TableCell RowSpan="13" Width="1%"/>                                    
                                    <asp:TableCell Width="20%" HorizontalAlign="Left">
                                        <asp:Label ID="lblOrderId" runat="server" Text="Order Id:"></asp:Label>
                                    </asp:TableCell>
                                    <asp:TableCell Width="25%" HorizontalAlign="Left">

0
Rosen
Telerik team
answered on 24 Aug 2010, 04:01 PM
Hi Gajanan,

From the pasted declaration it seems that you are using our "classic" RadGrid for ASP.NET,  which does not have the functionality in question implemented. Therefore you should manually set the CurrentPageIndex and rebind the grid control after the item is inserted or should consider upgrading to the RadControls for ASP.NET AJAX suite.

Best wishes,
Rosen
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
Gajanan
Top achievements
Rank 2
answered on 25 Aug 2010, 05:35 AM
hello Rosen

you are right i am using classic Radgrid control , you said we can set manually can you please tell me how can i set the manually
CurrentPageIndex and rebind the grid control after the item is inserted.

thank you
0
Rosen
Telerik team
answered on 25 Aug 2010, 12:07 PM
Hello Gajanan,

In order to navigate back to the first page after record has been inserted, you may use similar to the following code:

protected void RadGrid1_InsertCommand(object source,   Telerik.WebControls.GridCommandEventArgs e)
{
    //insert code...
    e.Canceled = true;
    e.Item.OwnerTableView.CurrentPageIndex = 0;
    e.Item.OwnerTableView.IsItemInserted = false;
    e.Item.OwnerTableView.Rebind();
}

Or in order to show the InsertItem form on the first page, you can try use the following code:

protected void RadGrid1_ItemCommand(object sender, Telerik.WebControls.GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.InitInsertCommandName)
    {
        e.Canceled = true;
        e.Item.OwnerTableView.IsItemInserted = true;
        e.Item.OwnerTableView.CurrentPageIndex = 0;
        e.Item.OwnerTableView.Rebind();
    }
}

Regards,
Rosen
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
Tags
Grid
Asked by
Gajanan
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Gajanan
Top achievements
Rank 2
Share this question
or