Link to home
Start Free TrialLog in
Avatar of Olukayode Oluwole
Olukayode OluwoleFlag for Canada

asked on

How can i ensure that data saved into a database thru a combobox withing a grid displays during retrieval

I have a Grid which i use in my c#  application  to enter and retrieve data

3 of the columns  loaded are from comboboxes  within the grid BUT do not show up at retrieval time ( see  screen below)

User generated image
The 3 columns (ItemID  , Project  and Department )  are properly populated into the Grid columns and i can select from the combo values

But on retrieval the 3 columns do not display the items stored in the database (see below the IteM ID and  Description  

from the database as shown below.

User generated image
NOTE that other fields in the Grid which are not loaded  from combo boxes show when retrieved

My script for  retrieval is the LINQ   statement below which works

     
         List<ARSalesDetailModel> variations = GlobalConfig.Connection.GetARSalesDetail();
         var data2 = (sender as ListBox).SelectedValue as ARSalesModel;
         dgvDetailsTable.DataSource = variations.Where(x => !x.ARSALEDDocumentNo.Equals(dgvtxtarsaleddocumentno.Selected) && data2.ARSALEDocumentNo.Equals(x.ARSALEDDocumentNo)).OrderBy(x => x.ARSALEDID).ToDataTable();


and my Load script for the combo  for Inventory Items is shown below (This also works as i select from the combo values and safe to the database)

dgvcmbarsaleditemid.DataSource = GlobalConfig.Connection.GetInventoryItems_All();
 dgvcmbarsaleditemid.DisplayMember = "FullInventoryList";
 dgvcmbarsaleditemid.ValueMember = "INVITEMId";


The Combo 3 Boxes load  properly , I am able to select from the combo boxes and safe same into the database  ( shown)

I have only shown 1 combo box  Item ID  not showing but it is the same story for the 2 other columns loaded from combos

How can i ensure  that data  from the database is displayed at retrieval time


Thanks

olukay
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Olukayode Oluwole

ASKER

Tried your suggestion in 2 places i thought it might be relevant

1. Just after LINQ  load the DataTable to the Grid  

The statement was flagged  ( see below  )

User generated image
and it flagged.

I then tried it at the point of Loading the Combo  (see below) It was flagged too

User generated image
It appears dgvcmbarsaleditemid.SelectedIndex does not exist because  SelectedIndex

does not exit


Where am I supposed to use the statement


Thanks


Olukay
Hi,

Am I right that grid has it's own data source and each of the comboboxes also has it's own datasource?
if yes, then it may be a matter of order when those datasources are refreshed

ziolko.
Hi ziolko

Thanks for your input.

I have already closd this thread  as an earlier siggestion  worked

Thanks


Olukay