On Gridview Updated Get All Modified Cells In A Textbox + Non Edited?
I'm trying to add in a textbox all values modified in cells + the others who aren't edited: table name : info columns : Name|Subname|Age|Birthday|Code I'm using on grid view updat
Solution 1:
You could use LINQ to get the necessary informations:
var changed = e.NewValues.Cast<DictionaryEntry>()
.Where(entry => entry.Value != e.OldValues[entry.Key])
.Select(entry => String.Format("{0} was edited with {1}",entry.Key,entry.Value));
var notChanged = e.NewValues.Cast<DictionaryEntry>()
.Where(entry => entry.Value == e.OldValues[entry.Key])
.Select(entry => String.Format("{0} was not changed",entry.Key));
TxtChanged.Text = String.Join(Environment.NewLine, changed);
TxtUnchanged.Text = String.Join(Environment.NewLine, notChanged);
Solution 2:
Right now you are not "adding" to the textbox, you are overwriting it with "="
Textbox1.text = GridView1.HeaderRow.Cells[i].Text + " " + e.OldValues[i].ToString() + " edited with " + e.NewValues[i].ToString();
Try this:
Textbox1.text += GridView1.HeaderRow.Cells[i].Text + " " + e.OldValues[i].ToString() + " edited with " + e.NewValues[i].ToString();
Changed the "=" for "+=".
And for the non edited values, something like? :
if(e.OldValues[i].ToString() != e.NewValues[i].ToString())
{
Textbox1.text += GridView1.HeaderRow.Cells[i].Text + " " + e.OldValues[i].ToString() + " edited with " + e.NewValues[i].ToString();
}
else
{
Textbox2.text += GridView1.HeaderRow.Cells[i].Text + " " + e.OldValues[i].ToString() + " didn't change";
}
Post a Comment for "On Gridview Updated Get All Modified Cells In A Textbox + Non Edited?"