I have a method (Win App C#) to fill DataGridView as below and used that in my TxB_ProitirySearch_TextChanged event:
void PrioFillGrid(bool IsSearching= false)
{
    if (IsSearching)
    {
        var ddd = from p in db.PDP_Priorities
                  where p.PriorityTitle.Contains(aski.Change(TxB_ProitirySearch.Text))
                  orderby p.ID descending
                  select new { p.ID, Title = p.PriorityTitle };
        if (ddd.Count() > 0)     // Solution1
        { 
            DG_Priority.DataSource = ddd; 
        }
        if (ddd != null)        // Solution2
        { 
            DG_Priority.DataSource = ddd; 
        }
        else
        {
            DG_Priority.DataSource = from p in db.PDP_Priorities
                                     orderby p.ID descending
                                     select new { p.ID, Title = p.PriorityTitle };
        }
    }
    else
    {
        DG_Priority.DataSource = from p in db.PDP_Priorities
                                 orderby p.ID descending
                                 select new { p.ID, Title = p.PriorityTitle };
    }
}
When I type a character, it's searching very well and updating data in gridview, but pressing backspace to clear the textbox and start a new search raises this exception:
An unhandled exception of type 'System.ArgumentNullException' occurred in System.Data.Linq.dll"
Value cannot be null. Parameter name: text
(Comment: aski.Change(TxB_ProitirySearch.Text) is a class to prevent unwanted characters from being saved in the database)
I'm wondering why both solution1 and 2 won't help.
Could anybody please help me?
Thanks in advance.
 
     
     
    