By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

How to get field value from current active record ?

P: 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
Share this question for a faster answer!
Share on Google+

Post your reply

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