如何将参数传递给用户控件? [英] how to pass parameter into a user control?

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

问题描述





如何将参数传递给用户控件并在我的页面中获取结果数据?

详细信息,In我的用户控件包含一个DropDownList,TextBox和Button.I hv将Query传递给用户控件,当页面在DropDownList中加载列名绑定时。我已将值放在textBox中并单击Button它将结果数据表返回到page.We在我的Page中的Gridview中绑定数据表。我使用C#.NET。



请帮助我。





问候,

Dev

解决方案

1。在控件中有一个公共属性,它将获取参数(可能包含在结构中)

2.在此属性的集合中执行所有绑定并将数据表保存在某个缓存中。

3.有另一个公共财产,其中get将返回此数据表。


这可能会对您有所帮助。检查一次

http://forums.asp.net/t/1155373.aspx [ ^ ]


< blockquote>如果你在aspx页面中有这样的控制:



< uc1:PrintProposalFees ID =PrintProposalFees1runat =server/>





传递代码后面的值,如下所示:



 this.PrintProposalFees1.ProposalID =3或你的价值; 







请记住控制ID不是控件!





并且在你的控制中放置这个属性:



 命名空间 UHSRFP.Features.UI 
{
public partial class PrintProposalFees:UserControl
{
private int myproposalID = -1;

public int ProposalID
{
get { return myproposalID; }
set {myproposalID = value ; }
}







全部


Hi,

How to pass parameter into a user control and get a result Datatable in my page?
In detail,In my user control contain one DropDownList,TextBox and Button.I hv pass the Query into user control,when the page load the column name bind in the DropDownList.I have put the value in textBox and click the Button it return the result datatable into the page.We bind the datatable in a Gridview in my Page.I have use C#.NET.

Please Help Me.


Regards,
Dev

解决方案

1. Have a public property inside the control that will take the parameters (possibly wrapped inside a struct)
2. in the set of this property do all the binding and save the datatable in some cache.
3. have another public property the get of which will return this datatable.


This may help you. Check once
http://forums.asp.net/t/1155373.aspx[^]


if you have such control in your aspx page :

<uc1:PrintProposalFees ID="PrintProposalFees1" runat="server" />


pass the values from code behind like this :

this.PrintProposalFees1.ProposalID= "3 or your value";




remeber to call the controll ID not the control!


AND in your control put this property:

namespace UHSRFP.Features.UI
{
    public partial class PrintProposalFees : UserControl
    {
       private int myproposalID = -1;

       public int ProposalID
       {
           get { return myproposalID ; }
           set { myproposalID = value; }
       }




thats all


这篇关于如何将参数传递给用户控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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