TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tharake Gunatilake
NA
53
73.2k
add multiple rows to a data grid view
Feb 12 2013 6:11 AM
I'm new to c#.
I want to add values of text boxes to a data grid view..I used this coding in the button click event.
DataTable table = new DataTable();
table.Columns.Add("STU_ID", typeof(string));
table.Columns.Add("NAME", typeof(string));
table.Columns.Add("ADDR", typeof(string));
table.Columns.Add("PHONE", typeof(string));
table.Columns.Add("EMAIL", typeof(string));
table.Columns.Add("BIRTHDATE", typeof(DateTime));
table.Columns.Add("SEX", typeof(string));
table.Rows.Add(textBox1.Text,textBox2.Text,textBox3.Text,textBox4.Text,textBox5.Text,dateTimePicker1.Value.ToString(),comboBox1.Text);
dataGridView1.DataSource = table;
It only add one row.When i try to add aothe set of values the grid view replaces the previous row.I need to keep the previous row and add the new row.
I d be very much thankful if someone can help me..
Reply
Answers (
4
)
List box1 to list box2 without duplication ?
Multilanguage C# application (.NET4 + Devexpress)