Reputation: 5845
I am using asp:GridView to display a data table in asp.net, .aspx page.
I have a column that contains sensitive information.
I would like to display the column with the data grayed out or any other method to hide it so there isn't just a huge visible list of this data column, when the page/gridview loads.
However, when the edit button is clicked on a particular row I would like the sensitive data in the column to be visible and editable.
Any ideas on how to achieve this?
Upvotes: 0
Views: 865
Reputation: 6780
you might want to use the rowdatabound event of the gridview to do your job. Find the specific control, (probably textbox) in the current row and then simply set disabled = true. Or you can also set visible=false to hide that particular control from that row. If I;m getting you properly, then this should do your job.
Upvotes: 0
Reputation: 13028
You can also, set a property on your page set to true or false when the edit button is clicked & switch control visibility like (this would work automatically during databind event)
private bool isEdit;
protected bool IsEditMode
{
get {return isEdit;}
set {isEdit=value;
}
Then in your aspx you will switch desired controls visiblity simply by
Visible='<%# IsEditMode %>'
Upvotes: 0
Reputation: 20620
Convert the column to a template.
Then you can edit the GridView templates. There are different templates for viewing and editing.
Upvotes: 1