如何在用户控件文本框中填写数据 [英] how to fiil data in usercontrol textboxes

查看:77
本文介绍了如何在用户控件文本框中填写数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用用户名和密码登录页面时,单击链接按钮后,我想在4个用户控制文本框中获取登录用户的数据.
我想根据登录ID和密码将数据从数据表中获取到用户控制文本框中.

when i login in a page with username and password and after i click a link button then i want to get the data of login user in 4 user control text boxes.
i want to get the data from data tables to user control text boxes based on login id and password

推荐答案

您是否正在验证用户名和密码?
还是您正在使用自定义控件来为您完成此操作?
Are you validating the Username and password?
Or are you using a custom controll to do it for you?


您可以使用属性来设置和获取私有变量.由于文本框是私有对象,因此您还可以在此处使用属性.
在用户控件中写一个属性来设置文本框的值
You can use properies to set and retreive a private variable. Since Textboxes are private objects , here also you can use properties .
In user control writ a property to set the value of the textbox
public string textValue
       {
           set
            {
             textBox1.Text = value;
            }
           
           get
             {
             return textBox1.Text;
             }
           
       }




您可以通过调用
在表单中访问此属性




You can access this property at you form by calling

userControl11.textValue = "the value for user control.";



您将通过
获得用户控制值



You will get the user control value by

string userctlvalue = userControl11.textValue;



希望对您有帮助:)



Hope this will help you :)


这篇关于如何在用户控件文本框中填写数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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