Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello,

How to fill datagrid from textboxes on button click in wpf?

I want to display records in datagrid from textboxes on button click event but i dont want from database and then when we click another save button, it should be save all records in database.

Please help me.

Thanks in Advance.

Ankit Agarwal
Software Engineer
Posted
Comments
Herman<T>.Instance 2-Apr-15 8:04am    
So? What have you tried?

1 solution

That's the most basic thing you can do with C#. You could have looked up for some solutions before posting. Anyways try this.
C#
private void button1_Click(object sender, EventArgs e)
{
    c.Open();
    string w = "insert into checkmultiuser(username) values (@username)";
    SqlCommand cmd = new SqlCommand(w, c);
    cmd.Parameters.Add("@username";, SqlDbType.VarChar);
    cmd.Parameters["@username";].Value = textBox1.Text;
    cmd.ExecuteReader();
    c.Close();
}
 
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