I am working on a web app where when the user enters data into a text box and presses a filter radio button it should filter the Gridview on the page to the criteria entered. I have done this before in previous applications with the same code listed below, but for some reason I am now getting the InvalidCastExeption error. Any help would be appreciated, the source database is SQL and the data field is set to nvarchar and I am using a string to compare as you will see in the code. I am just unsure why this worked in the past and is not working in this scenario.
Pete protected void filterLName_CheckedChanged(object sender, EventArgs e)
SHCDataContext existingCustomers = new SHCDataContext();
var filterExistingCustomers = existingCustomers.Customers.Where(c => c.custLastName.Contains(lNameTB.Text.ToString()));
displayCustGV.DataSource = null;
displayCustGV.DataSourceID = null;
displayCustGV.DataSource = filterExistingCustomers;
Here is the stack trace....
Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.I
View Complete Post