runtime made changes to dataset in c#.net
Hello any body help me on dataset changes accepting at runtime?
The Problem is
Step 1 I am getting data from database to dataset
Step 2 In this dataset I want to change one column value and display the changed value in grid view here is my co开发者_开发知识库de:
ds = dbManager.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetTranGridWithIMGEX");
for (int j=0; j < ds.Tables[0].Rows.Count; j++)
{
string DecryptText = ds.Tables[0].Rows[j][3].ToString().Trim();
MessageBox.Show(DecryptText);
string AfterDecrypText = DecryptString(DecryptText);
MessageBox.Show(AfterDecrypText);
ds.AcceptChanges();
}
dgvSummary.DataSource = ds;
dgvSummary.DataMember = "Table";
dgvSummary.Columns[11].Visible = false;
dgvSummary.Columns[13].Visible = false;
How to do this?
You're not updating the DataSet, so there are no changes to accept.
Add this line:
ds.Tables[0].Rows[j][3] = AfterDecryptText;
Then call ds.AcceptChanges().
Also, once you set the DataSource on the GridView, don't forget to call dgvSummary.DataBind()
.
精彩评论