473,387 Members | 1,532 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,387 software developers and data experts.

How to get field value from current active record ?

1
Hi people...

I am new to dotNet, specially to ADO.NET Entity framework. I have a problem... I can not find a way to get field value from current active row! Here is a code I use :

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Linq;
  9. using System.Data.Entity;
  10. using DevExpress.XtraEditors;
  11. using DevExpress.Utils.Menu;
  12. using newAWModel;
  13.  
  14. namespace KupciApp
  15. {
  16.   public partial class frmDoc : DevExpress.XtraEditors.XtraForm
  17.   {    
  18.  
  19.     LTEntities context;
  20.  
  21.     public frmDoc()
  22.     {
  23.       InitializeComponent();
  24.     }
  25.  
  26.     private void simpleButton1_Click_1(object sender, EventArgs e)
  27.     {
  28.       this.Close();
  29.     }
  30.  
  31.     private void frmDoc_Load(object sender, EventArgs e)
  32.     {
  33.       context = new LTEntities(); 
  34.       var query = context.Customers;
  35.       customerBS.DataSource = query.ToList();
  36.  
  37.     }
  38.  
  39.     private void simpleButton2_Click(object sender, EventArgs e)
  40.     {
  41.  
  42.       frmNewCustomer frmNewCust = new frmNewCustomer(10); // I would like to replace value 10 with current value of field CustomerID !
  43.       frmNewCust.Text = "New customer";      
  44.  
  45.       if (frmNewCust.ShowDialog(this) == DialogResult.OK)
  46.       {
  47.        context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Customers);
  48.       }
  49.  
  50.     }
  51.  
  52.     private void simpleButton4_Click(object sender, EventArgs e)
  53.     {
  54.       context.Refresh(System.Data.Objects.RefreshMode.StoreWins, context.Customers);
  55.       customerBS.ResetBindings(false);
  56.     }
  57.  
  58.  
  59.   }
  60. }
  61.  
Notice the "query.ToList();" I think bindingsource is the answer, but I can not simpe create a DataRow or DataRowView object and access field values because I use "ToList()" ! I am stuck! Please help !
Aug 26 '10 #1
0 1330

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

Similar topics

2
by: Eugene | last post by:
Hi, Problem: I need to get the value of auto-incremented field from just inserted record In Oracle this is INSERT .. RETURNING command. In SQL Server there are @@IDENTITY, IDENT_CURRENT,...
4
by: | last post by:
Something really common I'm sure and I'm surprised it's not just a field property option. The previous record's field value can be retrieved and copied into the current corresponding field by...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
3
by: Brenden Bixler | last post by:
I'm developing a large website with a substantial number of large forms - containing 40+ fields each. Writing the INSERT and UPDATE statements by hand is extremely laborious and time consuming. I...
8
by: Jeff | last post by:
A client wants a press of the Enter key in a field on a continuous form to grab the value of that field from the previous record. But if they have typed a value and then hit Enter it shouldn't. ...
1
by: roveagh1 | last post by:
Hi I've been using the 2 year old link below to repeat values from previous record field into current corresponding field. It's worked fine for text but the last piece of advice was to use the same...
4
by: Susan Bricker | last post by:
I have a form that displays record information in Continuous Record display (scrollable list). One of the fields in the record is an Integer value called "rcode" (reason code). But, I don't want...
2
by: cynicon | last post by:
Thank you guys for answering my last questions. Here is again a simple question with a simple answer I suppose... I need to know how to set in a Variable, the value of an especific column of...
2
by: banderson | last post by:
Hello Bytes, I am having trouble copying a value from an open record in a recordset into a form. I have a form frmOutreachReferral that is filled in after a Site Visit has been performed and it...
1
by: sarge721 | last post by:
I want to send a report to the currently selected student in my database. I have everything working fine, except pulling the e-mail address from the form. Rather than reading what I am writing as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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,...

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.