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

Rows.Count = 0 But SelectedRows.Count =1 Is there a bug?

1 Answer 64 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vicent
Top achievements
Rank 1
Vicent asked on 26 Feb 2020, 04:58 PM

I'm using static BindingList as DataSource:

public class Items
{
    public static DateTime FechaTrabajo = DateTime.Today;
    public static MyBindingList<Pedidos> pedidos = new MyBindingList<Pedidos>();
    public static async Task Load(DateTime fechaTrabajo)
    {
        try
        {
            pedidos.Clear();
            FechaTrabajo = fechaTrabajo;
            pedidos.Add(await SSEService.Instance.GetPedidos(fechaTrabajo));
            pedidos.ListUpdated();
        }
        catch (Exception) { }
    }
}

 

Where MyBindingList extends BindingList and ListUpdated is like:

public void ListUpdated()
{
    this.OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, 0));
}

 

I'm using Items.pedidos as datasource for the Grid and all is working perfect, grid is updating data when needed, but when I need selectedrows, if Items.pedidos has had data and now is empty. When I call:

private void bNuevoPalet_Click(object sender, EventArgs e)
{
    int rows = this.radGridView1.Rows.Count;
    int srows = this.radGridView1.SelectedRows.Count;
    if (this.radGridView1.SelectedRows.Count > 0)
    {
        Pedidos ped = this.radGridView1.SelectedRows[0].DataBoundItem as Pedidos;
        if (ped != null)
        {
            fPedido.ShowMe(ped);
        }
    }
}

 

rows = 0

but srows = 1

 

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 28 Feb 2020, 04:40 PM

Hello Vicent,

The provided detailed is greatly appreciated. I reproduced the described issue on my end and I confirm this is a bug. This is why I have logged it in our feedback portal by creating a public thread on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik Points as a reward.

To workaround this you can use the suggested solution:

Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    While Me.pedidos.Count > 0
        Me.pedidos.RemoveAt(0)
    End While
End Sub

I hope this helps. Do not hesitate to contact us if you have other questions.

Regards,
Nadya
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Vicent
Top achievements
Rank 1
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or