473,765 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databinding is not working properly for nested object

12 New Member
I save a "SalesRetur n" 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 "SalesRetur n" 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 1132

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

Similar topics

0
1741
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, that the update linkbutton actually goes to the edit command instead of the update command (which I'm pretty sure would be a bug). Anyway, I took out the editcommmand column and replaced it with a regular template column. Within the...
10
2024
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, Flash, JPEG and ASCII art versions. The first two are there because they print at much higher resolution than the JPEG, so I'm keen to keep them in if possible.
1
3302
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. However, when I try to access the same page from another machine or when I test the code on a remote server the images just wouldn't show. The page I am talking about has 3 Image web controls. In the CodeBehind I am loading these controls by using an...
5
2794
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 returns true. What can i do about it?? Regards, Nita
3
2707
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 nested class, I get the error message about "this" (the parent being readonly). When I leave out the ref keyword things compile, but I want to make sure I pass by reference so I can save memory. As you can see the
4
3252
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 makes a popup.. the pop up is actually a DIV tag.. with a GIF image in it......
12
4584
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 am tring to go back threw back button of Browser....it send me last visted pages(means sessons not expire properly). How can i solve it... One more thing is that the script is working properly on localhost....problem occures when i uploaded it on...
5
3616
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 log in. Every page has at the start: session_start(); ob_start();
3
2013
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" type="text/javascript"> function call() { var box=new Array(50);
4
3763
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 in IE and Fire Fox but dont work properly in Safari. does anyone know why its not working properly in safari and how i can get it to work? Your help would be much appreciated!
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9955
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5421
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.