PC Review


Reply
Thread Tools Rate Thread

Datagrid ( add row manually ) problem

 
 
Agnes
Guest
Posts: n/a
 
      14th Aug 2004
I got a Master-Detail relationship. Branch with dept (two tables) , as the
user input the Dept code, press 'Confirm' button,
I will select * from branch and input into the datatable mannually. the
dgBranchDept.datasource = myDataset. datamember= foreginconstraint_deptid.
I found the datatable got the data, but the datagrid display nothing. I
check the post before and try all the method. but still fail . please help

Here the following is my coding :---

drBranch = cmdBranch.ExecuteReader
dtSysBranchDept.BeginInit()
dgBranchDept.EndInit()
bmSysBranchDept.EndCurrentEdit()
Do While drBranch.Read
myDataRow = dtSysBranchDept.NewRow()
myDataRow.BeginEdit()
myDataRow.Item("branchid") = drBranch.Item("branchid")
myDataRow.item("deptid") = txtDeptId.Text
'MessageBox.Show(drBranch.Item("branchid")) <--- work fine
dtSysBranchDept.Rows.Add(myDataRow)
myDataRow.EndEdit()
Loop

drBranch.Close()
dtSysBranchDept.AcceptChanges()
Me.bmSysBranchDept.EndCurrentEdit()
dtSysBranchDept.EndInit()


 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      14th Aug 2004
Agnes,

As far as I can see is this code you are is exactly the same as what does
the dataadapter.fill with except setting the constraints, and the properties
of the datatable.

However why are you showing it, in my opinion is only importent that the
databinding for this to the datagrid is probably

\\\
dgBranchDept.datasource = dtSysBranchDept
///

A lot of work, to do it this way, I am curious what is the reason for that?

Cor

> I got a Master-Detail relationship. Branch with dept (two tables) , as the
> user input the Dept code, press 'Confirm' button,
> I will select * from branch and input into the datatable mannually. the
> dgBranchDept.datasource = myDataset. datamember= foreginconstraint_deptid.
> I found the datatable got the data, but the datagrid display nothing. I
> check the post before and try all the method. but still fail . please help
>
> Here the following is my coding :---
>
> drBranch = cmdBranch.ExecuteReader
> dtSysBranchDept.BeginInit()
> dgBranchDept.EndInit()
> bmSysBranchDept.EndCurrentEdit()
> Do While drBranch.Read
> myDataRow = dtSysBranchDept.NewRow()
> myDataRow.BeginEdit()
> myDataRow.Item("branchid") = drBranch.Item("branchid")
> myDataRow.item("deptid") = txtDeptId.Text
> 'MessageBox.Show(drBranch.Item("branchid")) <--- work fine
> dtSysBranchDept.Rows.Add(myDataRow)
> myDataRow.EndEdit()
> Loop
>
> drBranch.Close()
> dtSysBranchDept.AcceptChanges()
> Me.bmSysBranchDept.EndCurrentEdit()
> dtSysBranchDept.EndInit()
>
>



 
Reply With Quote
 
Agnes
Guest
Posts: n/a
 
      14th Aug 2004
Dear Cor,
I found my error, as my previous post ( branchid's field size is not the
same) . After I correct. Everything go fines.\
(quit strang)
Anyway, thanks a lot
"Cor Ligthert" <(E-Mail Removed)> ¦b¶l¥ó
news:(E-Mail Removed) ¤¤¼¶¼g...
> Agnes,
>
> As far as I can see is this code you are is exactly the same as what does
> the dataadapter.fill with except setting the constraints, and the

properties
> of the datatable.
>
> However why are you showing it, in my opinion is only importent that the
> databinding for this to the datagrid is probably
>
> \\\
> dgBranchDept.datasource = dtSysBranchDept
> ///
>
> A lot of work, to do it this way, I am curious what is the reason for

that?
>
> Cor
>
> > I got a Master-Detail relationship. Branch with dept (two tables) , as

the
> > user input the Dept code, press 'Confirm' button,
> > I will select * from branch and input into the datatable mannually. the
> > dgBranchDept.datasource = myDataset. datamember=

foreginconstraint_deptid.
> > I found the datatable got the data, but the datagrid display nothing. I
> > check the post before and try all the method. but still fail . please

help
> >
> > Here the following is my coding :---
> >
> > drBranch = cmdBranch.ExecuteReader
> > dtSysBranchDept.BeginInit()
> > dgBranchDept.EndInit()
> > bmSysBranchDept.EndCurrentEdit()
> > Do While drBranch.Read
> > myDataRow = dtSysBranchDept.NewRow()
> > myDataRow.BeginEdit()
> > myDataRow.Item("branchid") = drBranch.Item("branchid")
> > myDataRow.item("deptid") = txtDeptId.Text
> > 'MessageBox.Show(drBranch.Item("branchid")) <--- work fine
> > dtSysBranchDept.Rows.Add(myDataRow)
> > myDataRow.EndEdit()
> > Loop
> >
> > drBranch.Close()
> > dtSysBranchDept.AcceptChanges()
> > Me.bmSysBranchDept.EndCurrentEdit()
> > dtSysBranchDept.EndInit()
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Manually Add Row to Datagrid Jason Microsoft Dot NET 1 30th Sep 2005 10:23 AM
RE: DataGrid: how to make DataGrid sort manually? =?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?= Microsoft C# .NET 0 15th Apr 2005 04:15 PM
Add Row Manually to DataGrid DraguVaso Microsoft Dot NET Framework Forms 5 22nd Jul 2004 03:38 PM
Add Row Manually to DataGrid DraguVaso Microsoft VB .NET 5 22nd Jul 2004 03:38 PM
Add Row Manually to DataGrid DraguVaso Microsoft ADO .NET 5 22nd Jul 2004 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:12 PM.