c# - How to change values of column of DataTable and show only in DataGrid not updating actual table of database -
i have column encrypted name(all other columns not encrypted) in sql database table. , have decrypt column encrypted name show in datagrid users of application actual table of sql database should not changed.(has remain encrypted name).
i think updatecommand works update actual table , have find alternative below updatecommand.
or there alternative way decrypt 1 column on datatable not influencing actual table of database?
my simple code is,
sqlcommand gridcomm = new sqlcommand(); gridcomm.connection = conn; gridcomm.commandtext = "select id, customername, phonenumber customers"; sqldataadapter gridda = new sqldataadapter(gridcomm); sqldatareader gridreader = gridcomm.executereader(); while (gridreader.read()) { } gridreader.close(); datatable griddt = new datatable("customers"); gridda.fill(griddt); foreach (datarow row in griddt.rows) { string strcustomername = (string) row["customername"].tostring(); bytecustomername = convert.frombase64string(strcustomername); string decryptedcustomername = decryptstringfrombytes_aes(bytecustomername, byteaeskey, byteaesiv); row["customername"] = decryptedcustomername; } gridda.updatecommand = new sqlcommandbuilder(gridda).getupdatecommand(); datagrid_totalcustomerlist.itemssource = griddt.defaultview; gridda.update(griddt);
hello kay lee: think if @ implementing coverter in view looking for. in ivalueconverter implementation can implement decrypt routine. converter extended syntax in wpf binding statement. if not clear flesh out more. here great reference converters: http://www.wpf-tutorial.com/data-binding/value-conversion-with-ivalueconverter/
kind regards, mark wardell
Comments
Post a Comment