473,394 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Databinding is not working properly for nested object

I save a "SalesReturn" object in my library which has few objects as property.

Expand|Select|Wrap|Line Numbers
  1.     namespace BusinessObjects
  2.     {
  3.     public class SalesReturn : ObjectBase
  4.     {
  5.  
  6.         private Int32 pSalesReturnId;
  7.         private SalesPerson pSalesPersonDetails=new SalesPerson();
  8.         private PackSize pPackSizeDetails=new PackSize();
  9.  
  10.         public Int32 SalesReturnId
  11.         {
  12.             get { return pSalesReturnId; }
  13.             set
  14.             {
  15.                 if (!value.Equals(pSalesReturnId))
  16.                 {
  17.                     pSalesReturnId = value;
  18.                     PropertyHasChanged("SalesReturnId");
  19.                 }
  20.             }
  21.         }
  22.  
  23.         public SalesPerson SalesPersonDetails
  24.         {
  25.             get { return pSalesPersonDetails; }
  26.             set
  27.             {
  28.                 if (!value.Equals(pSalesPersonDetails))
  29.                 {
  30.                     pSalesPersonDetails = value;
  31.                     PropertyHasChanged("SalesPersonDetails");
  32.                 }
  33.             }
  34.         }
  35.  
  36.         public PackSize PackSizeDetails
  37.         {
  38.             get { return pPackSizeDetails; }
  39.             set
  40.             {
  41.                 if (!value.Equals(pPackSizeDetails))
  42.                 {
  43.                     pPackSizeDetails = value;
  44.                     PropertyHasChanged("PackSizeDetails");
  45.                 }
  46.             }
  47.         }
  48.  
  49.         public SalesReturn()
  50.         {
  51.         }
  52.  
  53.  
  54.         public static SalesReturn FillEntity(SQLiteDataReader Reader,SQLiteConnection Connection)
  55.         {
  56.             SalesReturn salesreturn = new SalesReturn();
  57.             salesreturn.pSalesReturnId = Convert.ToInt32(Reader["SalesReturnId"]);
  58.             salesreturn.SalesPersonDetails =SalesPerson.GetEntity( Convert.ToInt32(Reader["SalesPersonId"]),Connection);
  59.             salesreturn.pPackSizeDetails =PackSize.GetEntity( Convert.ToInt32(Reader["PackSizeId"]),Connection);
  60.             salesreturn.MarkOld();
  61.             return salesreturn;
  62.         }
  63.  
  64.         public static SalesReturn GetEntity(int salesReturnId, string ConnectionString)
  65.         {
  66.             SalesReturn salesreturn = null;
  67.             using (SQLiteConnection Connection = new SQLiteConnection(ConnectionString))
  68.             {
  69.                 Connection.Open();
  70.                 string sqlSelect = "SELECT SalesReturnId, SalesPersonId, PackSizeId FROM tblSalesReturn WHERE SalesReturnId=" + salesReturnId + "";
  71.                 using (SQLiteCommand cmd = new SQLiteCommand(sqlSelect, Connection))
  72.                 {
  73.                     SQLiteDataReader Reader = cmd.ExecuteReader();
  74.                     if (Reader.HasRows)
  75.                     {
  76.                         Reader.Read();
  77.                         salesreturn = FillEntity(Reader, Connection);
  78.                     }
  79.                     if (!Reader.IsClosed)
  80.                     {
  81.                         Reader.Close();
  82.                     }
  83.                 }
  84.                 Connection.Close();
  85.             }
  86.             return salesreturn;
  87.         }
  88.  
  89.     }
  90.     }
  91.  
I have a WinForm databound to this object. I am using a method to bind to that object.
Expand|Select|Wrap|Line Numbers
  1.         private void AddDataBindings()
  2.         {
  3.             bsSalesPerson.DataSource = SalesPerson.GetComboList(GlobalVariables.ConnectionString);
  4.             cmbSalesPersonDetails.DataSource = bsSalesPerson;
  5.             cmbSalesPersonDetails.ValueMember = "SalesPersonId";
  6.             cmbSalesPersonDetails.DisplayMember = "FullNameInEnglish";
  7.  
  8.             bsPackSize.DataSource = PackSize.GetComboList(GlobalVariables.ConnectionString);
  9.             cmbPackSizeDetails.DataSource = bsPackSize;
  10.             cmbPackSizeDetails.ValueMember = "PackSizeId";
  11.             cmbPackSizeDetails.DisplayMember = "ProductPackSize";
  12.             lblUnitName.DataBindings.Add("Text", bsPackSize, "UnitName");
  13.  
  14.             bsCurrentEntity.DataSource = typeof(SalesReturn);
  15.             cmbSalesPersonDetails.DataBindings.Add("SelectedItem", bsCurrentEntity, "SalesPersonDetails",false,DataSourceUpdateMode.OnPropertyChanged);
  16.             cmbPackSizeDetails.DataBindings.Add("SelectedItem", bsCurrentEntity, "PackSizeDetails", false, DataSourceUpdateMode.OnPropertyChanged);
  17.         }
  18.  
My problem is when i retrieve an existing "SalesReturn" object from database, databound comboboxes are not showing the appropriate value.
Expand|Select|Wrap|Line Numbers
  1.         private void LoadObject(object sender, EventArgs e)
  2.         {
  3.                 CurrentEntity = SalesReturn.GetEntity(salesReturnId, GlobalVariables.ConnectionString);
  4.                 bsCurrentEntity.DataSource = CurrentEntity;       
  5.         }
  6.  
I could not identify the problem. Would you please help me to identify it?
Jan 31 '13 #1
0 1117

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: NETDeveloper | last post by:
Hi, I almost have my nested datagrid working properly. I created a datagrid on a user control and dropped that onto another datagrid. At first, I noticed when I was stepping through the code,...
10
by: Philip Ronan | last post by:
Hi, I'm having problems embedding alternative content with nested OBJECT tags. Take a look at <http://www.japanesetranslator.co.uk/chihiro/map.html> The map on this page is available in SVG,...
1
by: Roberto Castro | last post by:
I have some problems with the way I am showing the BLOB fields in the Image web controls. It does work on my localhost though sometimes I need to hit Refresh for the images to load properly....
5
by: Nita Raju | last post by:
Hi, I have to validate a textbox for date without using the validation controls. So i had to use IsDate(). It's not working properly when i give "11//2004". When i enter the above date it...
3
by: mbaskey | last post by:
Hello... I have an object which has a nested object which need to look at the parent to return a value about it. Basically as below but when I put the ref method parameter to construct the...
4
by: Charleees | last post by:
GIFS not working properly in JavaScript PopUps Hi all, I have a button and when i click tha button it redirects to another page..... I have also added a java script for the button that...
12
kamill
by: kamill | last post by:
I have done a logout page for logout from admin section and provides a link to logout from admin section.Whenever i clicked on logout link it redirected to index.php of admin section......BUT when i...
5
by: damezumari | last post by:
When a user logs in to my site http://iwantyourquestion.com I set $_SESSION to true if his username and password are OK. When he calls a page I check if $_SESSION is true. If it not I ask him to...
3
by: rajasree | last post by:
Hi all, am doing a project in PHP. my javascript code is working properly in ie. But its not working in firefox. Please help me my code is as follows; <script language="javascript"...
4
by: zairali | last post by:
Hi, I am trying to fix a webpage ( http://www.d.umn.edu/itss/labs/maps/ ) which uses some html (or xml also?) to show pop ups when you rollover the numbers on a map of the building. They work fine...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.