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

Add record in Gridview while paging

2 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kristof
Top achievements
Rank 1
Kristof asked on 10 Jan 2011, 06:24 PM
Hi

Is it possible to add a new row into the gridview when you use paging?
without the paging it works, but our client would like to use paging.

I am using a datatable to fill up the datagrid (I receive this from a dll from a client).

VB

 

 

Dim pagedSource = New QueryableCollectionView(GetDataTable().AsEnumerable.ToList)
Me.radDataPager.Source = pagedSource
Me.radGridView.ItemsSource = pagedSource

XAML

 

 

 

 

<StackPanel 
    Orientation
="Horizontal" 
    HorizontalAlignment
="Center" 
    Margin
="0,5,0,0">

 

 

 

 

 

<telerik:RadButton 
    Width
="150" 
    Content
="Add new row" 
    Margin
="0,0,5,0" 
    
Command="telerikGrid:RadGridViewCommands.BeginInsert" 
    CommandTarget
="{Binding ElementName=RadGridView}" />

 

 

 

 

 

</StackPanel>

 

 

 

 

 

<telerik:RadDataPager 
    x
:Name="radDataPager" 
    PageSize="10" 
    DisplayMode
="All" 
    
IsTotalItemCountFixed="false" 
    
VerticalContentAlignment="Bottom"
</telerik:RadDataPager>

 

 

 

 

 

<telerik:RadGridView 
    x
:Name="radGridView" 
    ItemsSource="{Binding PagedSource, ElementName=radDataPager}" 
    VerticalAlignment="Top" 
    CanUserDeleteRows
="False" 
    CanUserInsertRows="True" 
    CanUserReorderColumns
="False" 
    ShowGroupPanel
="False" 
    AutoGenerateColumns
="False" 
    ShowInsertRow
="True">
</telerik:RadGridView>

 

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
SweNz
Top achievements
Rank 1
answered on 11 Jan 2011, 08:12 AM
I bind only DataPager (not bind to RadGridView) and it works fine (dynamic refresh grid after add new record and can paging).

public void GenerateDataPager()
{
    RadDataPager radDataPager = new RadDataPager();
    radDataPager.Source = SomeObj.GetData(); // return List<SomeObj>
}

hope this help :)

if you want to view my xaml go there > http://www.telerik.com/community/forums/wpf/gridview/got-double-record-when-add-a-record-via-radgrid.aspx

SweNz
0
Veselin Vasilev
Telerik team
answered on 11 Jan 2011, 09:30 AM
Hi Kristof,

You have set the ItemsSource of RadGridView in code behind and in XAML. Please remove the line:
Me.radGridView.ItemsSource = pagedSource
and try again.

All the best,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
GridView
Asked by
Kristof
Top achievements
Rank 1
Answers by
SweNz
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Share this question
or