views:

45

answers:

1

I have a FormView control with Two text Boxes. Data source for the Controls is an ObjectDataSource

I want to fetch these values from both text boxes, create a User object and pass it to ObjectDataSource, which has an input method that accept a User object

I think I have to do it in

protected void ObjectDataSourceUsert_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
        {  
            // string _userName = FormViewUserDetails. ?
            // string _password = FormViewUserDetails. ?

            User user = new User {UserName = _userName, Password = _password};
            e.InputParameters.Add(user);    
        }

Thanks

+1  A: 

If you're trying to find the controls inside the formview, you can use

TextBox myTextBox = (TextBox)MyFormView.Row.FindControl("controlID");
womp
It is not the control I need but the value It holds, can I avoid first creating a TextBox to get its value ?
Asad Butt
@adsi: the value of a `TextBox` is found in its `Text` property. Note that the `TextBox` object is not created (in normal cases) by the code above; the code merely fetches the `TextBox` object for you.
Fredrik Mörk
Thanks mate i have figured it out.
Asad Butt