Adding rows to dataset and bind to grid

M

mrajanikrishna

Hi,

I hv a datagrid and WinForm to enter new records.

da = new OleDbDataAdapter("select idno,ename,dob from emp",conn);
da.fill(ds,"emp");
BindGrid();

In the button click(AddNew),

DataTable dt = new ds.Tables["emp"];
DataRow newrow = dt.NewRow();
newrow["idno"]="XXXXXX";
newrow["ename"]="AAAAA";
....
dt.Rows.Add(newrow);

dgEmp.DataSource = ds.getChanges(DataRowState.Added);
dgEmp.DataBind();

Its adding new row. But every click, Its showing the current inserted
row in the datagrid but not previous one. I want to add as many
records as and finally update the datasource.

Whats the problem in my code
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top