Click here to Skip to main content
16,008,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
i have a dataGridView in a C# form,to view some data from DB sql server.i have some textBox in the form.
now i select one record in dataGridView and i want to see all fields of this record into those textBoxes.

please help
thanks
Posted
Comments
zyck 12-Feb-12 7:41am    
can you post your code?

1 solution

Let factorize your question into two parts

1) Display data from database into datagridview in C#

Read this article

How to populate DataGridView, GridView with SQL statement in C#[^]

2) Populate textboxes depend upon selected row in datagridview in C#.

C#
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString();
}


Hope this helps if yes then accept and vote the answer otherwise revert back with your queries
--Rahul D.
 
Share this answer
 
Comments
RDBurmon 12-Feb-12 7:50am    
Thanks mostafa
FM7 12-Feb-12 7:53am    
thanks Rahul Dhoble
FM7 12-Feb-12 7:54am    
i am bigener.hope to help me if i have problem in C#

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