Click here to Skip to main content
15,940,271 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:

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.

Updated 18-Mar-12 20:18pm
Lakxman 19-Mar-12 1:38am    
Explain your requirement in detail. Is that like you want to pass some value in to a 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
Sergey Alexandrovich Kryukov 19-Mar-12 2:33am    
Basically, that's it. A 5.
This may help you. Check once[^]
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:

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