Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataGridView
Message
From
07/11/2007 14:39:14
 
 
To
07/11/2007 11:22:46
General information
Forum:
ASP.NET
Category:
Forms
Title:
Environment versions
Environment:
C# 2.0
OS:
Vista
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01267049
Message ID:
01267379
Views:
9
Bonnie, I am having a strange behavior.

When I click on the edit button to bring the dialog form I always get the first row regarding where I move on my DataViewGrid.

I did debug it and I am passing the row with the corrent information. But somehow the producer form keeps showing the first row.

here is the click event on my form ( with a DataGridView ) that calls the producer form :
 private void btnProducerEdit_Click(object sender, EventArgs e)
   {
     //System.Diagnostics.Debugger.Break();
      int i = grdProducers.CurrentRow.Index;
      DataRow row = dsProducers.Tables["Producers"].DefaultView[i].Row;

      // row contains the right info from the DataViewGrid!!!
      Producer frmProducers = new Producer(row);
      frmProducers.Text = "Producers";

      frmProducers.ShowDialog();
   }
Here is the code for my Producer form :
public partial class Producer : Form
 {
   DataRow m_Row;
   public Producer(DataRow row)
   {
    //System.Diagnostics.Debugger.Break();
    // The row contains the correct data !!!!!!
    m_Row = row;
    InitializeComponent();
    }

    private void btnClose_Click(object sender, EventArgs e)
    {
       this.Close();
    }

    private void Producer_Load(object sender, EventArgs e)
    {
      System.Diagnostics.Debugger.Break();
      this.txtFirstName.DataBindings.Add("Text", m_Row.Table, "FirstName");
      this.txtLastName.DataBindings.Add("Text", m_Row.Table, "LastName");
      this.txtLicenseNumber.DataBindings.Add("Text", m_Row.Table, "LicenseNumber");
      this.txtAppointmentDate.DataBindings.Add("Text", m_Row.Table, "AppointmentDate");
      this.chkActive.DataBindings.Add("Checked", m_Row.Table, "Active"); 
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            m_Row.Table.AcceptChanges();
            this.Close();
        }
                
    }
Why the producers form keep showing the first row on my DataGridView eventhough I pass it the correct row information???



Segio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform