Manually fetch values from asp.net control
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 Us开发者_运维百科er 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
If you're trying to find the controls inside the formview, you can use
TextBox myTextBox = (TextBox)MyFormView.Row.FindControl("controlID");
精彩评论