Solved

DetailsView Control

Posted on 2006-10-30
3
284 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now