Link to home
Start Free TrialLog in
Avatar of dstark
dstark

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of gangwisch
gangwisch

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dstark
dstark

ASKER

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?
Avatar of dstark

ASKER

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.