Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:

DetailsView Control

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
dstark
Asked:
dstark
  • 2
1 Solution
 
gangwischCommented:
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
 
dstarkAuthor Commented:
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
 
dstarkAuthor Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now