473,670 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display decrypted text in databound controls

Hi

I have a table in an sql database that contains data that has been encrypted
using the DPAPI.

What I am trying to achieve is to bind several controls on a vb 2005 windows
form to those fields but display the decrypted data in the controls instead
of the encrypted data. I also want to use a binding navigator to scroll
through the records and to add/delete records. I don't have a problem with
the encryption/decryption but am having trouble doing it dynamically with the
bound controls.

I have tried using several of the bindingsource events but they seem occur
when opening the form or at other times.

Any assistance would be appreciated.
Ian
Jan 21 '07 #1
7 1728
Hi Ian,

This normally varies based on the databound controls. For simple
databinding, such as TextBox, you may use Binding.Parse/Format events to
customize the display in the TextBox. In Binding.Format event, you may
decrypt the underlying encrypted data and display the result clear text to
the UI. In Binding.Parse event, you should do the opposite: get the text in
the UI TextBox and encrypt it. The final encrypted data will be pushed into
the underlying datasource. The article below talks more details of the
Binding.Parse/Format events:
"Data binding concepts in .NET windows forms"
http://www.codeproject.com/vb/net/da...ngconcepts.asp

For DataGridView complex databinding, it provides similar
DataGridView.Ce llParsing/CellFormatting events which can leverage with the
same logic above.

Hope this helps.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 22 '07 #2
Hi Ian,

Thanks for your feedback.

I originally provided some sample code regarding using Binding.Parse/Format
events in the link below, for your information:
http://groups.google.com/group/micro...rk.windowsform
s.databinding/msg/a429f83e8a55212 3?hl=en&

Also, the article I provided in the last reply also contains sample code in
VB.net regarding how to use Binding.Parse/Format events:
"Data binding concepts in .NET windows forms"
http://www.codeproject.com/vb/net/da...ngconcepts.asp

I can not find a dedicate article regarding the usage of
DataGridView.Ce llParsing/CellFormatting events. Basicly, you may select
DataGridView control in the VS2005 designer and click the event icon in the
PropertyBrowser and find CellParsing/CellFormatting events in the event
list. Then you may double click to add an event handler for these 2 events.

Below is the official link for DataGridView.Ce llParsing event, which
contains the most useful guidelines and sample code regarding its usage:
http://msdn2.microsoft.com/en-gb/lib...datagridview.c
ellparsing.aspx

Anyway, if you still have any problem of getting this work for you, please
feel free to tell me, I will work with you, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 23 '07 #3
Here's an example from a posting I made back in November 2006 for
capturing and using the Format and Parse events on a DataGridView.

The OP was trying to change how the data is displayed, but
not how it's stored, so if the user puts in "75000", he wanted
it displayed as "75K", but stored as 75000. And when it's
brought in from the database, he wanted to convert it from
75000 to 75K. When it's put back, he wanted to translate it
the other way.

CellFormatting happens between the data source and the screen.
CellParsing happens between the screen and the data source.

Try this:

AddHandler myGrid.CellForm atting, AddressOf OnCellFormattin g
AddHandler myGrid.CellPars ing, AddressOf OnCellParsing

Private Sub OnCellFormattin g(ByVal object as Sender, _
ByVal e as DataGridViewCel lFormattingEven tArgs)

If e.ColumnIndex = myGrid.Columns( "columnIcareAbo ut") Then
'setting this to true signals the grid that this
' column is being dynamically updated. If you don't
' do this, you will get an infinite loop if you have
' also set the column to have its size automatically
' determined.
e.FormattingApp lied = True

'get the row being populated; format this cell
Dim row as DataGridViewRow = myGrid.Rows(e.R owIndex)
If e.Value = "75000" Then
e.Value = "75K"
End If
End If
End Sub

Private Sub OnCellParsing(B yVal object as Sender, _
ByVal e as DataGridViewCel lParsingEventAr gs)

If e.ColumnIndex = myGrid.Columns( "columnIcareAbo ut") Then
'get the row being populated; format this cell
Dim row as DataGridViewRow = myGrid.Rows(e.R owIndex)
If e.Value = "75K" Then
e.Value = "75000"
End If
End If
End Sub

Hope this helps.
Robin S.
-------------------
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:BX******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Ian,

Thanks for your feedback.

I originally provided some sample code regarding using
Binding.Parse/Format
events in the link below, for your information:
http://groups.google.com/group/micro...rk.windowsform
s.databinding/msg/a429f83e8a55212 3?hl=en&

Also, the article I provided in the last reply also contains sample
code in
VB.net regarding how to use Binding.Parse/Format events:
"Data binding concepts in .NET windows forms"
http://www.codeproject.com/vb/net/da...ngconcepts.asp

I can not find a dedicate article regarding the usage of
DataGridView.Ce llParsing/CellFormatting events. Basicly, you may
select
DataGridView control in the VS2005 designer and click the event icon
in the
PropertyBrowser and find CellParsing/CellFormatting events in the
event
list. Then you may double click to add an event handler for these 2
events.

Below is the official link for DataGridView.Ce llParsing event, which
contains the most useful guidelines and sample code regarding its
usage:
http://msdn2.microsoft.com/en-gb/lib...datagridview.c
ellparsing.aspx

Anyway, if you still have any problem of getting this work for you,
please
feel free to tell me, I will work with you, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 23 '07 #4
Hi Robin,

Thank you for sharing your code snippet!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 23 '07 #5
You're welcome. In all fairness, I figured that out with the help
of Brian Noyes' Data Binding book. It has some really cool stuff in it.

Robin S.
-------------------------------
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:zc******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Robin,

Thank you for sharing your code snippet!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.

Jan 23 '07 #6
Hi Robin ,

Yes, this is really a good book. As far as I know, there is free online
ebook for it on internet. :-)

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Jan 24 '07 #7
Thanks to you both

Got it working. Thanks very much, all of your information was very helpful
and has also given me a better understanding of VB.

Regards
ilr

"RobinS" wrote:
Here's an example from a posting I made back in November 2006 for
capturing and using the Format and Parse events on a DataGridView.

The OP was trying to change how the data is displayed, but
not how it's stored, so if the user puts in "75000", he wanted
it displayed as "75K", but stored as 75000. And when it's
brought in from the database, he wanted to convert it from
75000 to 75K. When it's put back, he wanted to translate it
the other way.

CellFormatting happens between the data source and the screen.
CellParsing happens between the screen and the data source.

Try this:

AddHandler myGrid.CellForm atting, AddressOf OnCellFormattin g
AddHandler myGrid.CellPars ing, AddressOf OnCellParsing

Private Sub OnCellFormattin g(ByVal object as Sender, _
ByVal e as DataGridViewCel lFormattingEven tArgs)

If e.ColumnIndex = myGrid.Columns( "columnIcareAbo ut") Then
'setting this to true signals the grid that this
' column is being dynamically updated. If you don't
' do this, you will get an infinite loop if you have
' also set the column to have its size automatically
' determined.
e.FormattingApp lied = True

'get the row being populated; format this cell
Dim row as DataGridViewRow = myGrid.Rows(e.R owIndex)
If e.Value = "75000" Then
e.Value = "75K"
End If
End If
End Sub

Private Sub OnCellParsing(B yVal object as Sender, _
ByVal e as DataGridViewCel lParsingEventAr gs)

If e.ColumnIndex = myGrid.Columns( "columnIcareAbo ut") Then
'get the row being populated; format this cell
Dim row as DataGridViewRow = myGrid.Rows(e.R owIndex)
If e.Value = "75K" Then
e.Value = "75000"
End If
End If
End Sub

Hope this helps.
Robin S.
-------------------
""Jeffrey Tan[MSFT]"" <je***@online.m icrosoft.comwro te in message
news:BX******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Ian,

Thanks for your feedback.

I originally provided some sample code regarding using
Binding.Parse/Format
events in the link below, for your information:
http://groups.google.com/group/micro...rk.windowsform
s.databinding/msg/a429f83e8a55212 3?hl=en&

Also, the article I provided in the last reply also contains sample
code in
VB.net regarding how to use Binding.Parse/Format events:
"Data binding concepts in .NET windows forms"
http://www.codeproject.com/vb/net/da...ngconcepts.asp

I can not find a dedicate article regarding the usage of
DataGridView.Ce llParsing/CellFormatting events. Basicly, you may
select
DataGridView control in the VS2005 designer and click the event icon
in the
PropertyBrowser and find CellParsing/CellFormatting events in the
event
list. Then you may double click to add an event handler for these 2
events.

Below is the official link for DataGridView.Ce llParsing event, which
contains the most useful guidelines and sample code regarding its
usage:
http://msdn2.microsoft.com/en-gb/lib...datagridview.c
ellparsing.aspx

Anyway, if you still have any problem of getting this work for you,
please
feel free to tell me, I will work with you, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent
issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each
follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach
the
most efficient resolution. The offering is not appropriate for
situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are
best
handled working with a dedicated Microsoft Support Engineer by
contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.


Jan 24 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2329
by: Ben R. | last post by:
I've got a repeater that's bound to a datareader and I'd like to conditionally modify the text that is being outputted. Previously, I've done this by assigning a name to attribute to the surrounding tablecell in which the <%# %> tags reside and I could use the findcontrol to grab a handle to the control by name and do any necessary modifications. I'm wondering if I can get around this? Is it necessary to assign a name to a surrounding cell?...
1
9533
by: Patrick Demets | last post by:
I have a fairly simple form with databound text boxes, but changes (or new records) are not recognized. The text boxes are successfully populated with data (from the database) and I can cycle through all the records. Using a datagrid works fine for updating. I've based this on the first sample project from the book "C# Professional Projects" (Premier Press). I've read many posts concerning this (and the MS KB as well), and most seem...
9
1545
by: Protoman | last post by:
Why doesn't this display the string? string decrypt(const string& ciphertext,const string& key) { string decrypted; decrypted.resize(ciphertext.size()); // allocates the string for the correct size. string::iterator itEnc=decrypted.begin(),itEnd=decrypted.end(); string::const_iterator itSource=ciphertext.begin(); string::const_iterator itKey=key.begin(),itKeyEnd=key.end();
3
1387
by: Felix_WafyTech | last post by:
Hi, I would like to create something similar to "The Code Project" message thread. You can see what I'm trying to explain by clicking on the link below: http://www.codeproject.com/aspnet/MasterDetail.asp?df=100&forumid=254259 Once the page opens, scroll down to the end of page. You will see message threads just like newsgroup threads. You can click on any of the Subject
5
14103
by: clickon | last post by:
This is driving me nuts, it is such a simply thing to do but i cannot for the life of me work out how you are suposed to do it. I want to update the data in DropDownListB based on what is selected in DropDownListA. I am not trying to do anything fancy with AJAX, i am happy to use Post Backs. If it were two controls just on the page then i would simply specify a control parameter for the SelectCommand of the SQLDataSource control which...
5
2501
by: Stephen | last post by:
Hi, Is there anyway I can make a column thats databound into a hyperlink to navigate to another page? Suppose I have 3 columns: SortOrder, Description, UserName for eg: <Columns> <asp:HyperLinkColumn Text="View" DataNavigateUrlField="UserId" DataNavigateUrlFormatString="ViewInfo.aspx?id={0}">
7
1750
by: | last post by:
I'm using ASP.NET 2.0, C#, SQL Server 2005, and databound controls like the DataList and the GridView. Right now I'm using SqlDataSource as part of very quick and dirty site; I'm not looking to tier things. I want the topmost/first data element in a particular control to NOT be displayed. This should be possible by either telling the renderer to hide the first element programmatically, or by deleting it from the data store that it has...
4
9659
by: parsifal | last post by:
Hi everyone :-) I am learning to use the Repeater control to display a list of data. Each of my list items (or rows, however you look at it) has some child items that are 1..N in length. So I'd like to be able to - within the Repeater's ItemTemplate - loop over those child elements and display some controls for each. Right now I'm simply trying to do a loop (e.g. <% For Each stuff as String in Eval("Things") ... Next %>, but that...
4
2063
by: seth_hickel | last post by:
With other solutions I would get a recordset, read each record and display data by formating my html as I wanted to display values of each record. I am trying to display data in a three column three row table with paging. How does this translate to ASP.NET - or - what ASP.NET tools do I use to accomplish this and how. Thank you.
0
8469
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8814
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8661
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7419
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5684
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4211
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2800
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2042
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1794
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.