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

Can't clear grid when focus is on a child element

4 Answers 71 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jeremy Murtishaw
Top achievements
Rank 1
Jeremy Murtishaw asked on 16 Jun 2009, 07:45 PM

Hi,
I'm trying to use a button to clear the results in my grid (see example below) and it works fine except for when I have focus on a child element of an expanded row.  If the focus is on any row that isn't a child then the clear button works without issue.  The error is "Object reference not set to an instance of an object."  for grdResults.DataSource.  where grdResults is the Telerik.WinControls.UI.RadGridView

private void cmdClear_Click(object sender, EventArgs e)
        {
             grdResults.DataSource = null;
        }

If the focus is on a child element when the clear button is clicked do I need to change focus to a non-child row and then set the DataSource to null?

Thanks,
Jeremy

4 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 17 Jun 2009, 12:29 PM
Hello Jeremy Murtishaw,

Thank you for reporting this issue. This is a bug in RadGridView and has been scheduled for fixing. Again thank you for the feedback.Your Telerik points have been updated.

Regards,
Victor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 17 Jun 2009, 02:55 PM

Thanks for your response Victor.  Until this is fixed, do you have any suggested workarounds?


0
Accepted
Prad
Top achievements
Rank 2
answered on 17 Jun 2009, 04:48 PM
WorkAround:

Set radgridview.columns.clear();
0
Jeremy Murtishaw
Top achievements
Rank 1
answered on 17 Jun 2009, 05:03 PM
Thanks Pradeep! 

Using radgrdview.columns.clear() worked well except it still left a blank column header across the top of my grid, so in order to completely clear it I ended up doing the following:

            try
            {
                radgrdview..DataSource = null;
            }
            catch (NullReferenceException)
            {
                radgrdview.Columns.Clear();
            }
Tags
GridView
Asked by
Jeremy Murtishaw
Top achievements
Rank 1
Answers by
Victor
Telerik team
Jeremy Murtishaw
Top achievements
Rank 1
Prad
Top achievements
Rank 2
Share this question
or