473,569 Members | 2,790 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Filter SQLdataSource

In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False" DataKeyNames="P roductID" DataSourceID="S qlDataSource1">

<Columns>

<asp:BoundFie ld DataField="Prod uctID" HeaderText="Pro ductID" InsertVisible=" False"ReadOnly= "True" SortExpression= "ProductID" />

<asp:BoundFie ld DataField="Prod uctName" HeaderText="Pro ductName" SortExpression= "ProductNam e" />

<asp:TemplateFi eld HeaderText="dro pdown">

<ItemTemplate >

<asp:DropDownLi st ID="DropDownLis t1" runat="server" DataSourceID="S qlDataSource2" DataTextField=" CustomerName" DataValueField= "CustomerID ">

</asp:DropDownLis t>

</ItemTemplate>

</asp:TemplateFie ld>

</Columns>

</asp:GridView>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSour ce>

<asp:SqlDataSou rce ID="SqlDataSour ce2" FilterExpressio n="ProductID='{ 0}'" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParamete rs>

<asp:ControlPar ameter Name="Title" DefaultValue="0 "/>

</FilterParameter s>

</asp:SqlDataSour ce>

Now, I would like to filter the sqlDataSource for dropdown list, to fill only that rows into dropdown which has productID equal to the productID of the row, where the dropdown is placed.

(so, sqlDataSource is fileterd dynamically for each row)

I was trying to do that with select parameter but no success. Now, I'm trying to do that with Filter parameter but also got stock.

Any example, idea, help?

Thanks,S

Mar 31 '06 #1
3 4516
Simon,

This walkthrough should help:

http://msdn2.microsoft.com/en-us/lib...94(VS.80).aspx

Regards,
--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"simonZ" <si*********@st udio-moderna.com> wrote in message news:eJ******** ******@tk2msftn gp13.phx.gbl...
In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False" DataKeyNames="P roductID" DataSourceID="S qlDataSource1">

<Columns>

<asp:BoundFie ld DataField="Prod uctID" HeaderText="Pro ductID" InsertVisible=" False"ReadOnly= "True" SortExpression= "ProductID" />

<asp:BoundFie ld DataField="Prod uctName" HeaderText="Pro ductName" SortExpression= "ProductNam e" />

<asp:TemplateFi eld HeaderText="dro pdown">

<ItemTemplate >

<asp:DropDownLi st ID="DropDownLis t1" runat="server" DataSourceID="S qlDataSource2" DataTextField=" CustomerName" DataValueField= "CustomerID ">

</asp:DropDownLis t>

</ItemTemplate>

</asp:TemplateFie ld>

</Columns>

</asp:GridView>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSour ce>

<asp:SqlDataSou rce ID="SqlDataSour ce2" FilterExpressio n="ProductID='{ 0}'" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParamete rs>

<asp:ControlPar ameter Name="Title" DefaultValue="0 "/>

</FilterParameter s>

</asp:SqlDataSour ce>

Now, I would like to filter the sqlDataSource for dropdown list, to fill only that rows into dropdown which has productID equal to the productID of the row, where the dropdown is placed.

(so, sqlDataSource is fileterd dynamically for each row)

I was trying to do that with select parameter but no success. Now, I'm trying to do that with Filter parameter but also got stock.

Any example, idea, help?

Thanks,S

Mar 31 '06 #2
Thank you Justin, but that is not what I'm looking for.

Example belov shows how to bind dropdown list in edit mode. That is no problem.

In my example I have to show dropdownlist in gridView in normal mode
(there is no eny edit mode or selected column that I could use key columns of gridView)

Any idea?

regards,S
"S. Justin Gengo" <justin@[remove to send mail]aboutfortunate. com> wrote in message news:eR******** ******@TK2MSFTN GP11.phx.gbl...
Simon,

This walkthrough should help:

http://msdn2.microsoft.com/en-us/lib...94(VS.80).aspx

Regards,
--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"simonZ" <si*********@st udio-moderna.com> wrote in message news:eJ******** ******@tk2msftn gp13.phx.gbl...
In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False" DataKeyNames="P roductID" DataSourceID="S qlDataSource1">

<Columns>

<asp:BoundFie ld DataField="Prod uctID" HeaderText="Pro ductID" InsertVisible=" False"ReadOnly= "True" SortExpression= "ProductID" />

<asp:BoundFie ld DataField="Prod uctName" HeaderText="Pro ductName" SortExpression= "ProductNam e" />

<asp:TemplateFi eld HeaderText="dro pdown">

<ItemTemplate >

<asp:DropDownLi st ID="DropDownLis t1" runat="server" DataSourceID="S qlDataSource2" DataTextField=" CustomerName" DataValueField= "CustomerID ">

</asp:DropDownLis t>

</ItemTemplate>

</asp:TemplateFie ld>

</Columns>

</asp:GridView>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSour ce>

<asp:SqlDataSou rce ID="SqlDataSour ce2" FilterExpressio n="ProductID='{ 0}'" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParamete rs>

<asp:ControlPar ameter Name="Title" DefaultValue="0 "/>

</FilterParameter s>

</asp:SqlDataSour ce>

Now, I would like to filter the sqlDataSource for dropdown list, to fill only that rows into dropdown which has productID equal to the productID of the row, where the dropdown is placed.

(so, sqlDataSource is fileterd dynamically for each row)

I was trying to do that with select parameter but no success. Now, I'm trying to do that with Filter parameter but also got stock.

Any example, idea, help?

Thanks,S

Apr 3 '06 #3
Simon,

It's the same thing. You just convert the regular mode's column to a template view and do the same things you would have done in edit mode. The two different modes don't matter the technique is the same for either template.

Regards,

--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"simonZ" <si*********@st udio-moderna.com> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Thank you Justin, but that is not what I'm looking for.

Example belov shows how to bind dropdown list in edit mode. That is no problem.

In my example I have to show dropdownlist in gridView in normal mode
(there is no eny edit mode or selected column that I could use key columns of gridView)

Any idea?

regards,S
"S. Justin Gengo" <justin@[remove to send mail]aboutfortunate. com> wrote in message news:eR******** ******@TK2MSFTN GP11.phx.gbl...
Simon,

This walkthrough should help:

http://msdn2.microsoft.com/en-us/lib...94(VS.80).aspx

Regards,
--
S. Justin Gengo
Web Developer / Programmer

Free code library:
http://www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"simonZ" <si*********@st udio-moderna.com> wrote in message news:eJ******** ******@tk2msftn gp13.phx.gbl...
In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False" DataKeyNames="P roductID" DataSourceID="S qlDataSource1">

<Columns>

<asp:BoundFie ld DataField="Prod uctID" HeaderText="Pro ductID" InsertVisible=" False"ReadOnly= "True" SortExpression= "ProductID" />

<asp:BoundFie ld DataField="Prod uctName" HeaderText="Pro ductName" SortExpression= "ProductNam e" />

<asp:TemplateFi eld HeaderText="dro pdown">

<ItemTemplate >

<asp:DropDownLi st ID="DropDownLis t1" runat="server" DataSourceID="S qlDataSource2" DataTextField=" CustomerName" DataValueField= "CustomerID ">

</asp:DropDownLis t>

</ItemTemplate>

</asp:TemplateFie ld>

</Columns>

</asp:GridView>

<asp:SqlDataSou rce ID="SqlDataSour ce1" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSour ce>

<asp:SqlDataSou rce ID="SqlDataSour ce2" FilterExpressio n="ProductID='{ 0}'" runat="server" ConnectionStrin g="<%$ ConnectionStrin gs:NorthwindCon nectionString %>" SelectCommand=" SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParamete rs>

<asp:ControlPar ameter Name="Title" DefaultValue="0 "/>

</FilterParameter s>

</asp:SqlDataSour ce>

Now, I would like to filter the sqlDataSource for dropdown list, to fill only that rows into dropdown which has productID equal to the productID of the row, where the dropdown is placed.

(so, sqlDataSource is fileterd dynamically for each row)

I was trying to do that with select parameter but no success. Now, I'm trying to do that with Filter parameter but also got stock.

Any example, idea, help?

Thanks,S

Apr 3 '06 #4

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

Similar topics

5
4464
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a ControlParameter <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XYZ %>"
8
5023
by: Mike Kelly | last post by:
I've chosen to implement the "optimistic concurrency" model in my application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to my main tables. I read the value of the column in my select, remember it, and then use it in the update. It works just fine when I have full control of the whole process. I want to do the same for...
3
5060
by: zapov | last post by:
Hi! Did anyone successfully managed to use some custom ADO.NET provider with SqlDataSource? I'd like to connect to some other database than MSSQL (like MySQL, Firebird or PostgreSQL) but I'm having problems making this work. Inside connectionStrings I added my name, provider and connectionString but for some reason SqlDataSource is trying...
2
1365
by: A. J. | last post by:
Hi, I'm new to ASP.Net 2.0, and I have two pages login.aspx which contain the membership login control with SQL database, and second page data.aspx which contain FormView. I need to use SessionParameter to pass the UserName and do some filteration to display the required information. The fields are UserName, Email.
5
7679
by: msch-prv | last post by:
Hi, I am trying to tie a SQLDataSource control to MySQL without success. The connection string works ok with an ObjectDataSource. (Native asp.net 2.0 MySQL dll loaded in /bin) For some reason, the compiler believes an SQL db is being accessed ("An error has occurred while establishing a connection to the server. When connecting to SQL...
2
1987
by: djc | last post by:
1) I am wondering if I should be using an sqlDataSource object for my particular scenario. I need to loop through a listbox and perform an INSERT sql operation for each item. Could be a few or several items. The reason I'm wondering if I should use an SqlDataSource object is overhead. For example, prior to learning about the sqlDataSource I...
0
2737
by: joebob8000 | last post by:
This seems like a simple task, but my 6 year old roots in classic ASP must be causing me trouble with my current problem. I am looking to provide a search for users in which they can select multiple categores (check boxes) and view only the results in those categories in a gridView control. My goal is to do so for movies, so an example would...
2
2076
by: Julien Sobrier | last post by:
Hello, I have 2 SqlDataSource on the same page that retrieve the same column names: <asp:SqlDataSource ID="SqlStructure" runat="server" SelectCommand="SELECT a, b FROM c WHERE d = 0 /> <asp:SqlDataSource ID="SqlSons" runat="server" SelectCommand="SELECT a, b FROM c WHERE d = 74" /> The problem is that Eval("a") always return the value...
8
2542
by: Cirene | last post by:
I have a dropdownlist that is bound to a query. Is it possible to further filter the items after the fact? The dropdownlist is inside a createuserwizard/createuserstep/contenttemplatecontainer. Thanks.
0
7694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7666
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
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...
0
5217
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...
0
3651
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...
0
3636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2107
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
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.