This is a migrated thread and some comments may be shown as answers.

Password Box in GridView

4 Answers 126 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bryan Johnson
Top achievements
Rank 1
Bryan Johnson asked on 31 Aug 2010, 04:38 PM
I'm using a password box inside of a RadGridView cell.  I'm also using buttons with the gridview commands to control the editing behavior of the grid.  It works pretty well except that if the only field changed is the password field, the 'Save Insert/Edit' button is not enabled.  I actually have to edit another field in the same row and then the button becomes enabled and I can save the changes.  The updated password is then written to the database via a web service.  Is there a different way to bind the password box to the grid cell so that it works better with the gridview command buttons?  I've included my code below:

<telerik:GridViewDataColumn DataMemberBinding="{Binding password, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Header="Password">
<telerik:GridViewDataColumn.CellTemplate>
    <DataTemplate>
        <PasswordBox Password="{Binding password, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
    </DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>

4 Answers, 1 is accepted

Sort by
0
Accepted
Veselin Vasilev
Telerik team
answered on 02 Sep 2010, 10:00 AM
Hi Bryan Johnson,

The button will become enabled only when the grid is in edit mode. Clicking in the password box which is in the CellTemplate will not enter the edit mode of the grid.

I suggest that you try the following:

1. Set the EditTriggers="CellClick" property of the gridview

2. Define the column like this:

<telerik:GridViewDataColumn DataMemberBinding="{Binding password}"
                            Header="Password">
    <telerik:GridViewDataColumn.CellTemplate>
        <DataTemplate>
            <TextBlock Text="**********" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellTemplate>
    <telerik:GridViewDataColumn.CellEditTemplate>
        <DataTemplate>
            <PasswordBox Password="{Binding password, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" />
        </DataTemplate>
    </telerik:GridViewDataColumn.CellEditTemplate>
</telerik:GridViewDataColumn>

Hope this helps.

All the best,
Veselin Vasilev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bryan Johnson
Top achievements
Rank 1
answered on 02 Sep 2010, 02:11 PM
That worked.  Thanks!
0
Joris
Top achievements
Rank 2
answered on 14 Aug 2012, 09:35 AM
Hi all, first of all thank you for posting this question and reply. This was a great help.

Unfortunately I have a small problem with this when validating the value. 
In VB if I ask Len(e.NewValue.ToSting I get a Null value in return.

Cloud you please advise how to get the value from the passwordbox.

Thanks in advance,
Joris

I've found it.

e.EditingElement.Password

Didn't think of looking into the object itself.
0
Brian
Top achievements
Rank 1
answered on 06 Nov 2012, 03:58 PM
The solution provided above by Veselin unfortunately does not work any more, as the WPF PasswordBox cannot be data bound any more due to security concerns. Is there another angle I can use to achieve the same results?

BP
Tags
GridView
Asked by
Bryan Johnson
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Bryan Johnson
Top achievements
Rank 1
Joris
Top achievements
Rank 2
Brian
Top achievements
Rank 1
Share this question
or