473,779 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass parameter to DataSet via user control?


Hi,

I've defined an ObjectDataSourc e and a parameterized DataSet. I would like
it if I could pass the parameter value that describes the query that creates
the DataSet as part of a user control declaration. Here's how the parameter
is described in the context of my ObjectDataSourc e:

<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
SelectMethod="G etArticlesByWho mever"
TypeName="Whate verTableAdapter s.WhateverTable Adapter">
<SelectParamete rs>
<asp:Paramete r DefaultValue="8 3" Name="PersonID" Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>

The query that's part of the DataSet has a standard @Parameter string, and
I've verfied that it is working with the DefaultValue I'm passing.

Can somone tell me how to set a differnet Parameter value using a value
passed from a User Control and/or programmaticall y?

Thanks,

-KF
Nov 19 '05 #1
1 7758
Answering my own question: here's 3/4 of the answer. I am still figuring out
how to pass a parameter directly from the user control to the query that
defines the ObjectDataSourc e -- if someone could answer that, I'd appreciate
it. For anyone looking for a simple example of how ObjectDataSourc e can be
parameterized, example follows.

-KF

Steps:
1) Configure your ObjectDataSourc e query to accept a parameter
2) Include a <asp:ControlPar ameter ... (nested as a SelectParameter ) that
includes a default value you wish to pass and a binding to a ControlID.

Elaborating that:
1) SELECT Contentitems.Co n_Title, ...
WHERE ( (Contentitems.S ta_StatusID <> 666 ) AND ...
(Persons.Per_Pe rsonID = @PersonID)
2)
<asp:ObjectData Source ID="odsArticles ByStaff" runat="server"
OnSelecting="Ob jectDataSource1 _Selecting"
SelectMethod="G etArticlesByUwn ewsStaff"
TypeName="Artic lesByUwnewsStaf fTableAdapters. uwnStaffArticle sTableAdapter">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="Drop DownList1" DefaultValue="8 3"
Name="PersonID"
PropertyName="S electedValue" Type="Int32" />
</SelectParameter s>
</asp:ObjectDataS ource>
<asp:ObjectData Source ID="odsUwnewsSt aff" runat="server"
SelectMethod="G etNewsReleaseAu thorsDT"
TypeName="uwnew s_NewsReleaseAu thorsTableAdapt ers.DataTable1T ableAdapter">
</asp:ObjectDataS ource>
<asp:DropDownLi st ID="DropDownLis t1" runat="server"
DataSourceID="o dsUwnewsStaff" DataTextField=" Per_SurName"
DataValueField= "Per_Person ID">
<asp:ListItem Value="83">Name 1</asp:ListItem>
<asp:ListItem Value="1">Name2 </asp:ListItem>
</asp:DropDownLis t>
<asp:Button ID="Button1" runat="server" Text="submit" />


<ke*****@u.wash ington.edu> wrote in message
news:eg******** ******@TK2MSFTN GP15.phx.gbl...

Hi,

I've defined an ObjectDataSourc e and a parameterized DataSet. I would like
it if I could pass the parameter value that describes the query that
creates the DataSet as part of a user control declaration. Here's how the
parameter is described in the context of my ObjectDataSourc e:

<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
SelectMethod="G etArticlesByWho mever"
TypeName="Whate verTableAdapter s.WhateverTable Adapter">
<SelectParamete rs>
<asp:Paramete r DefaultValue="8 3" Name="PersonID" Type="Int32"
/>
</SelectParameter s>
</asp:ObjectDataS ource>

The query that's part of the DataSet has a standard @Parameter string, and
I've verfied that it is working with the DefaultValue I'm passing.

Can somone tell me how to set a differnet Parameter value using a value
passed from a User Control and/or programmaticall y?

Thanks,

-KF

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
7744
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control which will be used to query sql server to repopulate the datagrid in the user control. I also wrapped the user control in a panel element so I could position it on the page. I'm clueless on how to get started with this.
7
5731
by: moondaddy | last post by:
I'm building a page in vb.net with several user controls on it. I'm using user controls instead of a frames page since I've seen this recommended many times in this user group. I want just one of the user controls to do a postback but not the rest of the page. Is this possible? it seems like it should be. If it is, please explain how I can do it. Thanks. -- moondaddy@nospam.com
5
3960
by: Ben | last post by:
Hi I am using a User Control which is referenced by an ASPX page. How can I pass a string parameter to the user control, from the base ASPX page. Thanks Ben
1
1831
by: pei_world | last post by:
I have a user control: - using LoadControl("MyCtrl.ascx") MyCtrl _mycontrol = (MyCtrl)LoadControl("MyCtrl.ascx") Page.Controls.Add(_mycontrol); _mycontrol.Text it will be loaded when some events fired. so how can I pass value to this user control from aspx template file.
1
4573
by: Stanley Cheung | last post by:
Dear all, how can I pass a parameter to dynamic user control? As I know we can pass parameter into traditional user control. e.g: add pageid into user control and write a property from user control <uc1:uccc id="uccc1" runat="server" pageid="1"></uc1:uccc> I can create dynamic user control but don't know how to pass parameter into user control.
2
3131
by: rhungund | last post by:
Hi all. I have a user control I'm using as my "include" file for my flash navigation. My asp.net app is written in vb.net. The swf file takes a parameter which I would like to pass into my user control. Ideally i'd like to do something like this: <object type="application/x-shockwave-flash" data="flash/navigation.swf?page=<%pageName%>" width="850" height="148"> <param name="movie" value="flash/navigation.swf?page=<%pageName%>" />...
4
2656
by: simon | last post by:
hello. relatively new to vb.net, i'm using VS 2003 and .net 2.0 i have a web app that i'm i have a user control that displays a simple 1 row table as the header of the page. the user control takes one input variable, the string that will be displayed as the title of the page. example call: <uc1:Header runat=server ID="ucHeader" Title="Home Page" /> what i am looking to do on a certain page is have the "title" value be dynamic, in...
9
3694
by: keith | last post by:
I use this code to load a user control at runtime: Control c = Page.LoadControl(Request.ApplicationPath + "/User_Controls/website_design.ascx"); UserControlPlaceHolder.Controls.Add(c); Immediately after loading the control, I need to set a property of the user control. I have tried various ways of directly referencing the control without success. I have also tried using FindControl, but all I get is a null value.
3
1918
by: jeet11 | last post by:
Hi all i want to fill the gridview on selected index changed event of a dropdown that is in user control and gridview is in main form .how i can? pls help.
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10306
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8961
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7485
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.