Question : find  button

1)in asp.net I have a button on the aspx page. can I handle button events in a class?

2) can I assign a label a value from a class?

Answer : find  button

How to filter your data source depends on what type of datasource you use...

For DataTable, you can use BindingSource.Filter or DataView or in some cases SqlDataSourceView.FilterExpression.

From your code above, it looks like the datasource you use (datasourceaccountnature) is a collection (of EntityCollection<T>) type.

Typically for collections as datasource in gridview, the filtering can be done as shown in the code below:

See if this helps.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
public class YourClass
        {
            EntityCollection<AccountnatureEntity> datasourceaccountnature;

            private void PopulateGrid()
            {
                // datasourceaccountnature is now a class member

                datasourceaccountnature = new EntityCollection<AccountnatureEntity>(new AccountnatureEntityFactory());

                var bucketaccountnature = new RelationPredicateBucket();

                ... // other code not shown here
            }

            private void textBox1_TextChanged(object sender, EventArgs e)
            {
                // datasourceaccountnature is the one you used in PopulateGrid method in your code.
                // Make datasourceaccountnature as member of the class so that we can use it here.

                dataGridView1.DataSource = datasourceaccountnature.FindAll(FilterList);
            }

            private bool FilterList(AccountnatureEntity a)
            {
                // to filter by a field of AccountnatureEntity
                // return true if that field value contains the text entered by user in textBox1
                // otherwise return false.

                // for example if AccountnatureEntity has a field named 'Title', then 
                return a.Title.Contains(textBox1.Text);
            }
        }
Random Solutions  
 
programming4us programming4us