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

Odd Behavior after changing CurrentRow

2 Answers 115 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phillip Foster
Top achievements
Rank 1
Phillip Foster asked on 30 Jul 2010, 07:49 PM
Ok I have a GridView on my form. The GridView datasource is a DataTable. 
the datatable columns types are:    bool (checkbox), text, text, text.
I set all the grid columns to read only except for the first one, to allow the user to check/uncheck to box. 

I also have a timer that ticks every 7 seconds and refreshes the datatable. 
Everything works fine to this point. 

Within the tick event i save the selected row, and then select it again after the data refresh, so the highlighted row doesn't pop back up to the top. 

private void tTickets_Tick(object sender, EventArgs e)
{
   int selectedrow = gridview.CurrentCell.RowIndex;
   GetData();
   gridview.CurrentRow = gvMassTickets.Rows[selectedrow];
}


 
The problem is, when it does this, column[0] (the check box column) becomes readonly. 
if i comment out the "gridview.CurrentRow = gvMassTickets.Rows[selectedrow];"
it works just fine. 


2 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 02 Aug 2010, 05:35 PM
Hello Phillip,

Try setting the columns to be readonly true / false with: radGridView.MasterTemplate.Columns[0].ReadOnly = true / false, and if this still doesn't work please give me additional details about what happens in GetData()

Best Regards,
Emanuel Varga
0
Alexander
Telerik team
answered on 04 Aug 2010, 05:18 PM
Hello Phillip,

Thank you for contacting us.

We investigated the case you described and this helped us to find the following issue in RadGridView: if RadGridView is in EditMode, some changes of the DataSource object are made and the current row is changed, the EditMode becomes permanent. We will address this issue in a future version.

As a workaround you can use the CurrentRowChanging event to cancel changing the current row if the RadGridView control is in EditMode:
private void radGridView1_CurrentRowChanging(object sender, Telerik.WinControls.UI.CurrentRowChangingEventArgs e)
{
    if (this.radGridView1.IsInEditMode)
    {
        e.Cancel = true;
    }
}

It should correct the control's behavior in your scenario.

Best Regards,
Alexander
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
GridView
Asked by
Phillip Foster
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or