For this you can easily create a protected method and use databind to display the username in the txt User Name Text Box.But, now the question is that how will you update the username or send the username to the database.You cannot use Control Parameter since the name of the Text Box for each Grid View row is different.You can however add assign the parameter in the Sql Data Source Updating event.So, the method in the code behind page would look like something like this: However, decrypting the data using a templatefield tag posed another problem, extracting new values from the ‘Text Box1’ control.This will be solved when calling the Item Updating event.
The legacy code in the SQL data source used a update statement with parameters.
Recently I was tasked with encrypting/decrypting some data that could be edited using ASP. Along with the details view control, the legacy code used a SQL Data Source to select and update everything.
This means the data access layer was bypassed completely, so any business logic that dealt with encryption on this page had to use a different execution path. The problem could be divided into two tasks: The first task was the easier of the two, as it just involved referencing the encryption library from the code behind page and calling the function inline in the aspx page.
First let's take a look at the simple update which does not dynamically assign the parameters.
In the example below I am using a simple Grid View control and updating the User Name, First Name and Last Name.