Click here to Skip to main content
12,405,853 members (69,604 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ADO.NET
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 18-Mar-12 19:32pm
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?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
SAKryukov 19-Mar-12 2:33am
   
Basically, that's it. A 5.
--SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

This may help you. Check once
http://forums.asp.net/t/1155373.aspx[^]
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Simply Add Public property to your User Control and use User Control ID to refer it.

sample site
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 17 Nov 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100