Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DataGridView and DataSet , Update and AccpetChanges

DataGridView and DataSet , Update and AccpetChanges

Scheduled Pinned Locked Moved C#
databasequestionannouncement
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    half life
    wrote on last edited by
    #1

    Hi, the situation is this : i have a datagridview bound to a dataset. when i click on a button i've got on every datagridviewRow i need to update the changes in the same row, the thing is that i need also to change a column named "status" in the same row here is the event :

       private void dgvCalibrtion\_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
    
            if( e.ColumnIndex == 6)
            { 
                    UpdateCalibrtionData((dgvCalibrtion.Rows\[e.RowIndex\].DataBoundItem as DataRowView).Row, e.RowIndex);
                    TA\_CalibrationData.Update((dgvCalibrtion.Rows\[e.RowIndex\].DataBoundItem as DataRowView).Row);
                    dS\_StationManager.T\_CalibrationData.AcceptChanges();
             
    
            }
        }
    

    the thing is that the change in the column status //Cell[2]// never send to the DB the Datagridview shows the string ("Valid", ... ) but does'nt pass the change to the *.mdb, Neither the color of the string is changed. but all the other manually changes to the datagridview ( input from user ) is updated o.k. //Here i'm changing the value of the cell myself//

        private void UpdateCalibrtionData(DataRow dgvDataRow, int RowIndex)
        {
    
            DateTime ncalTime = (DateTime)dgvDataRow.ItemArray\[3\];
    
            if (ncalTime < DateTime.Now)
            {
                dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Style.ForeColor = Color.Red;
                dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Value = "Date Expired";
                return;
            }
    
            if (ncalTime > DateTime.Now)
            {
                if (ncalTime < DateTime.Now.AddDays(SM\_ApplicationData.Instance.CalibrationThreshold))
                {
                    TimeSpan dayDiff = (DateTime.Now - ncalTime);
                    int dDays = -(dayDiff.Days - 1);
                    dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Style.ForeColor = Color.Orange;
                    dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Value = "will expire in" + dDays.ToString() + " Days";
                    return;
                }
    
                dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Value = "Still Valid";
                dgvCalibrtion.Rows\[RowIndex\].Cells\[2\].Style.ForeColor = Color.Green;
            }
        }
    

    any one??? :) :) :) Have a nice day

    Have Fun Never forget it

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups