Click here to Skip to main content
15,880,543 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have text box and a button
After button click we have to show that data in my datagrid in windows.
Posted
Comments
Mohd. Mukhtar 27-Nov-12 1:15am    
What have you tried??

 
Share this answer
 
Try this it may help u

C#
private void button1_Click(object sender, EventArgs e)
      {
       DataTable dtToGrid = new DataTable();
        DataRow drToGrid;
        dtToGrid.Columns.Add(new DataColumn("EMP_ID", typeof(string)));
        dtToGrid.Columns.Add(new DataColumn("EMP_FName", typeof(string)));
        dtToGrid.Rows.Add();
        dtToGrid.Rows[0][0] = txt_empid.Text;
        dtToGrid.Rows[0][1] = txt_fname.Text;

        dataGridView.DataSource = dtToGrid;
      }
 
Share this answer
 

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