Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a register form for students and I need to have a gridview with a textbox and a button above the gridview to search students by studentID. I am beginner in C# and I don`t know what should I do and which codes I need for gridview and searchbox.please help me
Posted
Comments
Maciej Los 31-Oct-15 16:01pm    
And..
What have you tried?
BillWoodruff 31-Oct-15 16:14pm    
Time to start studying, then. Start by reading the documentation and examples for DataGridView. Search CodeProject for articles that will help you understand how to use the DataGridView.

There's at least few ways to achieve that:
1) using stored procedure
How to: Execute a Stored Procedure that Returns Rows[^]
How to: Execute a Query Using a Stored Procedure with In and Out Parameters[^]

2) using Filter[^] for binding source
DataGridView BindingSource.Filter Windows Forms Sample[^]

3) adding Dropdown to DataGridView's Headers
Building a Drop-Down Filter List for a DataGridView Column Header Cell [^]

4) using Linq To Dataset[^]
Querying DataSets (LINQ to DataSet)[^]

5) etc.

Try something and get back here when you get stuck to ask detailed question.
 
Share this answer
 
con.Open();
da = new OleDbDataAdapter(" select *from tablename where studentID ='" + textbox1.Text + "'", con);
            DataSet ds = new DataSet();
            da.Fill(ds, "tablename");
            dataGridView1.DataSource = ds.Tables[0];
            ds.Tables.Clear();
            con.close();
 
Share this answer
 
Comments
Maciej Los 1-Nov-15 12:09pm    
Wrong approach! Never, ever use such of queries! Use parametrzed queries.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900