Sometimes we want to get current page data from gridview. In my case, I want to update current view data as read. Here is the code:
private void UpdateAsRead()
{
//get header
foreach (DataControlField col in gvForm.Columns)
{
//Response.Write(col.HeaderText);
}
//get data
foreach (GridViewRow row in gvForm.Rows)
{
int i = 1;
foreach (TableCell cell in row.Cells)
{
//get all rows
if (i == 1)
{
GeneralDao gen = new GeneralDao();
//Response.Write(cell.Text + "
");
string strSQL = @"UPDATE TMIForm SET ldate ='" + gen.GetDateTime() + @"', luserid='" + GetUsername + @"'
WHERE id = '" + cell.Text + @"'";
frmDao.Update(strSQL);
}
i += i;
if (i == 7) { i = 1; }
}
}
}
0 komentar:
Posting Komentar