how to get only the edited row and save the date as modified date?
i have 6 fields in sql server:
dtl_id = int
cost = decimal
startdate = datetime
enddate = datetime
status = varchar
modified_date = datetime (modified_date is declare in sql as getdate)
.
this is my gridview:
modified_date: visible=false
| ID | cost | start date | end date | status | modified_date |
--------------------------------------------------------------
| 1 | 66.00| 1/02/13 | 1/20/13 | active | 1/02/13 |
| 2 | 12.00| 2/21/13 | 2/30/13 | active | 2/21/13 |
| 3 | 67.00| 3/28/13 | 3/10/13 | active | 3/28/13 |
-------------------------------------------------------------
| 4 | 20.00| 10/21/13 | 11/28/13| active | 10/21/13 |
-------------------------------------------------------------
|Add|
|SAVE|=insert/update data to sql database
when i edit the 4th row and i click the SAVE button it should update in sql and save the modified_date(datetime now). but in my code, all data in gridview and its modified_date are modifying. i want only to save/update the edited row..pls. help me .
here's my code:
foreach (GridViewRow row in gvw.Rows)
{
HiddenField dtl = (HiddenField)row.FindControl("hfDtl");
TextBox cost = (TextBox)row.FindControl("estimated_cost");
DateTimeControl dtissued = (DateTimeControl)row.FindControl("date_issued");
DateTimeControl dexp = (DateTimeControl)row.FindControl("expiration_date");
TextBox resp = (TextBox)row.FindControl("responsible");
DropDownList stat = (DropDownList)row.FindControl("status");
string msg = string.Empty;
msg = maDDL.submitItem(id.ToString(), Convert.ToInt32(dtl.Value).ToString(), Convert.ToDateTime(dtissued.SelectedDate).ToString()
, txtCode.Text.ToString(), txtArea.Text.ToString(), txtDesc.Text.ToString()
, Convert.ToDecimal(cost.Text).ToString(), Convert.ToDateTime(dexp.SelectedDate).ToString()
, resp.Text.ToString(), stat.SelectedItem.Text.ToString()
);
if (msg == "Record has been successfully saved!")
{
ShowMessage(msg);
}
else
{
Panel1.Visible = true;
lblMsg.Text = msg;
lblMsg.ForeColor = System.Drawing.Color.Red;
}
}
tnx in advance.