如何将参数传递给用户控件?

编程入门 行业动态 更新时间:2024-10-03 00:34:00
本文介绍了如何将参数传递给用户控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

解决方案

1。在控件中有一个公共属性,它将获取参数(可能包含在结构中) 2.在此属性的集合中执行所有绑定并将数据表保存在某个缓存中。 3.有另一个公共财产,其中get将返回此数据表。

这可能会对您有所帮助。检查一次 forums.asp/t/1155373.aspx [ ^ ]

如果你在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 forums.asp/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

更多推荐

如何将参数传递给用户控件?

本文发布于:2023-11-03 04:29:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554236.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控件   如何将   参数   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!