locked
count rows in rad gridview itemsource... RRS feed

  • Question

  • hi to all...

    is there any way that i can count total number of rows/record in rad gridview in silverlight...

    Sunday, May 22, 2011 2:45 AM

Answers

  • thanks to all...

    i found it... its like...

    int i = datagridCollection.Items.Count;

    Thursday, August 11, 2011 8:29 PM

All replies

  • i am using telerik rad gridview...

    Sunday, May 22, 2011 2:49 AM
  • i acn do count in datagrid... like

    var count = dataGrid1.ItemsSource.OfType<object>().Count();


    but i am unable to count rows in itemsource of telerik rad gridview...

    Sunday, May 22, 2011 4:08 AM
  • Hi Dizki,

    Should not count at collection data source.

    Sunday, May 22, 2011 4:23 AM
  • Should not count at collection data source.???

    hi thaicarrot... thanks for your reply but what does that mean...

    Sunday, May 22, 2011 4:40 AM
  • Could you show us how did you populate data for the Grid?

    Sunday, May 22, 2011 5:04 AM
  • yeah sure why not... i thought you are going to help me... but you are also asking for something... here is the code...

    public partial class testpage : Page
        {
            public ObservableCollection<MyItemClass> ItemsList { get; set; }
            public testpage()
            {
                InitializeComponent();


                ItemsList = new ObservableCollection<MyItemClass>();

               dataGrid1.ItemsSource = ItemsList;

            }

            // Executes when the user navigates to this page.
            protected override void OnNavigatedTo(NavigationEventArgs e)
            {
            }

            private void button1_Click(object sender, RoutedEventArgs e)
            {
                ItemsList.Add(new MyItemClass(textBox1.Text, textBox2.Text));
            }

        }

    -------------------------------------------------------------------------------

    public class MyItemClass
        {
            public string Description { get; set; }
            public string Number { get; set; }

            public MyItemClass(string description, string number)
            {
                this.Description = description;
                this.Number = number;
            }
        }

    -----------------------------------------------------------------

    <sdk:DataGrid ItemsSource="{Binding ItemsList}" AutoGenerateColumns="True" Height="100" HorizontalAlignment="Left" Margin="10,10,0,0" Name="dataGrid1" VerticalAlignment="Top" Width="324" />

    <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="10,120,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />


            <TextBox Height="23" HorizontalAlignment="Left" Margin="10,153,0,0" Name="textBox1" VerticalAlignment="Top" Width="120" />


            <TextBox Height="23" HorizontalAlignment="Left" Margin="136,153,0,0" Name="textBox2" VerticalAlignment="Top" Width="120" />

    Sunday, May 22, 2011 6:19 AM
  • Should not like following?

    var count = ItemsList.Count;

    Sunday, May 22, 2011 6:42 AM
  • thanks to all...

    i found it... its like...

    int i = datagridCollection.Items.Count;

    Thursday, August 11, 2011 8:29 PM