I have a GridView combine with data from SQL Server.
I want the GridView to show all the Movies and customers names and last names, by choosing the first letter of the movie only. The user will input the first letter in the TextBox.
I think <asp:ControlParameter can be used here but I don't know how.
Here its design:
Searching the forum, I found something like this solution, but it gave me an error - System.NullReferenceException:
protected void Button1_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(TextBox1.Text))
{
(GridView1.DataSource as DataTable).DefaultView.RowFilter = string.Format("FirstName LIKE '{0}%'", TextBox1.Text);
}
}
Will be glad for some clues,
Thank you in advance!


GridView1.DataSource as DataTableis null since that code is executed before data is bound to the GridView.