手动获取从asp.net控制值 [英] Manually fetch values from asp.net control

查看:116
本文介绍了手动获取从asp.net控制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框FormView控件。为控制数据源是一个ObjectDataSource

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

我要来从两个文本框中这些值,创建一个用户对象,并把它传递给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

我想我必须这样做,在

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);    
        }

感谢

推荐答案

如果你想找到FormView控件内部的控件,您可以用

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

TextBox myTextBox = (TextBox)MyFormView.Row.FindControl("controlID");

这篇关于手动获取从asp.net控制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆