2

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 Answer 1

1

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

TextBox myTextBox = (TextBox)MyFormView.Row.FindControl("controlID");
Sign up to request clarification or add additional context in comments.

3 Comments

It is not the control I need but the value It holds, can I avoid first creating a TextBox to get its value ?
@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.
Thanks mate i have figured it out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.