how to add record programmatically to datagrid

J

jaYPee

Anyone know how to add record to a datagrid programmatically?

Say for example I have two textboxes in my form and a datagrid. When I
click a button the value of two textboxes will be added as a new row
to my datagrid.

Thanks in advance.
 
C

chandan

jaYPee said:
Anyone know how to add record to a datagrid programmatically?

Say for example I have two textboxes in my form and a datagrid. When I
click a button the value of two textboxes will be added as a new row
to my datagrid.

Thanks in advance.

HI ,
Its simple u just put it in DATASET
and bind the data grid with the dataset
Add the items in Dataset Datatable
In data table add new row.
 
J

jaYPee

I have already tried this w/ dataset but the problem is it doesn't
work w/ the grand child of my relationship

I have ask this before but doesn't recieved any response. here's the
question I made before.

My problem now is on how can I solve the problem when adding
a new record to my table.

This is my source code that works perfectly if I set the table to
"SchYrSemCourseJoin"

Dim dr As DataRow =
DsStudentCourse1.Tables("SchYrSemCourseJoin").NewRow()
dr("CourseID") = intcourse + 1

DsStudentCourse1.Tables("SchYrSemCourseJoin").Rows.Add(dr)

This code works perfectly if the datamember of my datagrid is set to
"SchYrSemCourseJoin". However because I am using a parent/child form
so the actual datamember of my datagrid is
"Students.StudentsSchYrSem.SchYrSemSchYrSemCourseJoin" and the
datasource is "DsStudentCourse1"

My purpose with this code is to add a new row to a datagrid.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top