Click here to Skip to main content
15,885,044 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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
Posted
Updated 18-Mar-12 20:18pm
v2
Comments
Lakxman 19-Mar-12 1:38am    
Explain your requirement in detail. Is that like you want to pass some value in to a asp.net user control and then connect to your DB and use the passed value for retrieving some records?

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.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-Mar-12 2:33am    
Basically, that's it. A 5.
--SA
This may help you. Check once
http://forums.asp.net/t/1155373.aspx[^]
 
Share this answer
 
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:

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

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



thats all
 
Share this answer
 
Simply Add Public property to your User Control and use User Control ID to refer it.

sample site
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900