关于用户控制 [英] Regarding about user control

查看:75
本文介绍了关于用户控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

我在执行用户控件时遇到一些问题.问题是
如下:-

1.我在用户控件中定义了功能添加.例如,当我添加该公司添加数据库的公司数量并关闭用户控件时,我在列表框中添加了公司数量

2.但是问题现在开始了.添加公司后,该公司未显示在父页面上,所以我的问题是如何刷新中继器控件和数据源

如何在Asp.net中刷新sqldataSource?

如何从用户控件访问父页面的控件?

请尽快帮助我

在高级中感谢!!

Dear Sir,

I have some problem when i am implementing the user control.The problem is
as follows:-

1.I am define the function add in the user control.for example I have add Number of companies in the list box when i am add the number of companies this companies add the database and close the user control

2.But the problem is started now. When you have add companies this companies not shown on the parents page so my question is how to refresh the repeater control and data source

How to refresh sqldataSource in Asp.net?

How to access Parent Page''s Control from an User Control?

Please help me as soon as possible

thanks in advanced !!

推荐答案

请勿尝试从用户控件访问父页面控件-这意味着您无法重用它.
而是在用户控件中创建一个事件(Changed是一个好名字),如果有兴趣更新其信息,则以父表单订阅该事件.
Do not try to access the parent page controls from a user control - it means that you cannot reuse it.
Instead, create an event in the user control (Changed is a good name) and subscribe to it in the parent form if it is interested in updating it''s information.
public event EventHandler Changed;
protected virtual void OnChanged(EventArgs e)
    {
    if (!ignoreChanges)
        {
        EventHandler eh = Changed;
        if (eh != null)
            {
            eh(this, e);
            }
        }
    }


这篇关于关于用户控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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