如何在组合框更改事件发生的地方加载用户控件? [英] How to load user control where combobox change event occur?

查看:65
本文介绍了如何在组合框更改事件发生的地方加载用户控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户控件在我的控件中我有一个datagridview当用户更改组合框值时它将刷新datagridview.below是我的代码但它的加载完全控制并刷新它我只想刷新datagridview



i have a user control in my control i have a datagridview when ever user change combobox value it will refresh datagridview.below is my code but its load full control and refresh its i want only refresh datagridview

if (metroComboBox1.DataSource !=null)
            {
                var id = metroComboBox1.SelectedValue.ToString();
                UserControl obj = new UserControl(id);
                this.panal1.control.add(obj);
            }





我的尝试:





What I have tried:

if (metroComboBox1.DataSource !=null)
            {
                var id = metroComboBox1.SelectedValue.ToString();
                UserControl obj = new UserControl(id);
                this.panal1.control.add(obj);
            }

推荐答案

您可以使用select中的select命令将网格的数据源属性提供给访问数据库的方法btn点击您用来访问或存储数据的事件,如[[ Datagridview.Datasource =Bll.Mymethod(); ]]如果使用三层艺术结构,您可以使用的是Mymethod();它将使用新值刷新网格
You can Provide the Datasource Property of the grid to method which is accessing the database using select command in your btn click event of what ever event your using to access the or store the data like[[ Datagridview.Datasource="Bll.Mymethod();]] if using the three tier artitecture else you can use is Mymethod(); it will refresh your grid with new values


如果您只需要一个控件或一组控件来更新回发,那么将它们放在更新面板中.Google asp.net updatepanel有关如何执行此操作的教程。
If you only want a single control, or set of controls, to update on a postback then put them in an updatepanel. Google "asp.net updatepanel" for tutorials on how to do this.


这篇关于如何在组合框更改事件发生的地方加载用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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