用户控件中设置的数据源 [英] Datasource set in a user control

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

问题描述

嘿,

我正在创建一个用户控件,想知道一些事情.我如何能够将用户控件设置为具有数据源属性(如列表视图或转发器).

现在,我有一个属性,需要填充一个已经作为对象数据源存在的集合,我想再次使用该对象数据源并将其设置在用户控件中,而不是第二次调用select方法.我将如何去做?

(如图所示,如果我可以像列表视图一样在用户控件中设置集合的数据源,那么将被设置,但是如果我有其他建议的开放方式.用户控件的datasource属性应该只设置另一个用户控件内部的属性添加到数据源的集合中)(如果这样也没有任何意义,请让我重新解释一下)

Hey,

I''m creating a user control and was wondering about something. How would I be able to set the user control to have a datasource property like a listview or repeater.

Right now I have a property that I need populated with a collection that already exists as an object data source, I want to use that object data source again and set it in the user control instead of recalling the select method a second time. How would I go about doing so?

(Figure if I could just set a datasource of the collection in the user control like a listview then I would be set but if there is another way I''m open to suggestions. The user control''s datasource property should only set another property inside the user control to the collection of the datasource)(Also if this doesn''t make any sence ask me to re-explain sorry)

推荐答案

您的用户控件中有一个DataSource属性,在它的设置部分中,您将值绑定到了用户控件中的内部gridview或数据列表,这应该很简单,您无需在内部再次调用查询您的用户控件.

后面的用户控制代码
Well, you have a DataSource property in your user control, in the set part of it you bind the value to the internal gridview or datalist you have in your user control, this should be straight forward, you don''t recall the query again in within your user control.

User Control code behind
public object DataSource
{
  set
  { 
    this.grdBills.DataSource =value;
  }
}



当然,这是一个例子.



Of course this is an example.


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

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