Solved

DetailsView Control

Posted on 2006-10-30
3
290 Views
Last Modified: 2012-05-05
I have a detailsview control on my page.  The purpose of this control (for now) is to perform inserts on a table.

However, I want to run a function against one of the elements before the submit happens.

IE - I have a field for password.. I want to hash that password using a public function called passwordHash(string pwdToHash).

so > Input password > click insert > run passwordHash() > save to database

How do I do that?
0
Comment
Question by:dstark
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
gangwisch earned 125 total points
ID: 17836479
here's a suggestion:

  Sub CustomerDetailView_ItemCommand(ByVal sender As Object, ByVal e As DetailsViewCommandEventArgs)
   
        If e.CommandName = "Add" Then

            ' Add the current store to the contact list.
     
            ' Get the row that contains the store name. In this
            ' example, the store name is in the second row (index 1)  
            ' of the DetailsView control.
            Dim row As DetailsViewRow = CustomerDetailView.Rows(1)
            Dim mycell As String = row.Cells(1).Text
row.cells(1).text=passwordhash(mycell)
       
        End If
   
    End Sub
0
 
LVL 1

Author Comment

by:dstark
ID: 17836835
I think this is close..

However, rows.Cells(1) is returning nothing. . rows.Cells(0) is returning the "Password", but it looks like rows.Cells(1).Text is return the text of the <td> and not the textbox control that has the data..

If that makes any sense..

Any advice?
0
 
LVL 1

Author Comment

by:dstark
ID: 17836992
protected void DetailsView1_ItemCommand(object sender, DetailsViewCommandEventArgs e)
    {
        if (e.CommandName == "Insert")
        {
            DetailsViewRow row = DetailsView1.Rows[1];
            TextBox tmpPwdBox = row.Cells[1].Controls[1] as TextBox;
            string tmpPwd = tmpPwdBox.Text;
            tmpPwdBox.Text = passwordHash(tmpPwd);          
        }
    }

Not the prettiest, but it seems to work.. I posed it here incase I ever need it again.
Thanks for help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question