PC Review


Reply
Thread Tools Rate Thread

Copy From Datagrid to Datagrid

 
 
=?Utf-8?B?amdyaW1zbWFu?=
Guest
Posts: n/a
 
      10th Jul 2004
I have 2 datagrids, dg1 and dg2, both attached to different tables. The application is for something like an order entry system, where all available items are in dg2, and a user can either dbl click or hit a button to copy the selected row from dg2 to dg1.

I can set up a DataRow and set the values for each cell manually and insert into dg1, but for some reason cannot figure out how to extract the values from dg2 to put into that DataRow for insertion.

Here is my current code:

Dim key As String = Me.DataGridView2.SelectedCells.Item(1).RowIndex

ItemOrdered = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemName()
ItemType = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemType()
ItemPrice = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemPrice()
ItemTranslation = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemTranslation()

When I run this, it throws a "StrongTyping_CannotAccessDBNull"

Does anyone know what that means?
 
Reply With Quote
 
 
 
 
=?Utf-8?B?amdyaW1zbWFu?=
Guest
Posts: n/a
 
      10th Jul 2004
Figured it out.

Changed code to:

ItemOrdered = Me.DataGridView2.SelectedRows.Item(0).Cells(1).Value
ItemType = Me.DataGridView2.SelectedRows.Item(0).Cells(2).Value
ItemPrice = Me.DataGridView2.SelectedRows.Item(0).Cells(4).Value
ItemTranslation = Me.DataGridView2.SelectedRows.Item(0).Cells(3).Value

Which worked like a charm.

"jgrimsman" wrote:

> I have 2 datagrids, dg1 and dg2, both attached to different tables. The application is for something like an order entry system, where all available items are in dg2, and a user can either dbl click or hit a button to copy the selected row from dg2 to dg1.
>
> I can set up a DataRow and set the values for each cell manually and insert into dg1, but for some reason cannot figure out how to extract the values from dg2 to put into that DataRow for insertion.
>
> Here is my current code:
>
> Dim key As String = Me.DataGridView2.SelectedCells.Item(1).RowIndex
>
> ItemOrdered = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemName()
> ItemType = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemType()
> ItemPrice = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemPrice()
> ItemTranslation = Me.SNDBDataSet.Menu.FindByMenuItemID(key).MenuItemTranslation()
>
> When I run this, it throws a "StrongTyping_CannotAccessDBNull"
>
> Does anyone know what that means?

 
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
MVVM: Single datagrid row selection when a datagrid contains anotherdatagrid in side RowDetailsTemplate Sunita@.NET Microsoft C# .NET 0 12th Nov 2010 09:03 AM
How to add a Dropdown list to a datagrid at runtime (dynamic) without using template columns in ASP.NET and still have the ability to us the datagrid Update event. Daniel Roth Microsoft Dot NET Framework 0 5th Apr 2005 04:54 AM
Filling One DataGrid Based on Selection from Another DataGrid - Both in Separate User Controls thegame Microsoft ASP .NET 1 28th Feb 2005 04:23 PM
Added CheckBox to a DataGrid Doesn't work with DataGrid.Enabled=False Amar Microsoft ASP .NET 0 6th Apr 2004 11:14 AM
Need Help Determining DataGrid Column Selected for Sort using IBindingList - Datagrid.zip (0/1) David Elliott Microsoft Dot NET Framework Forms 1 18th Jul 2003 02:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:10 AM.