473,415 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,415 software developers and data experts.

Filter SQLdataSource

In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1">

<Columns>

<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" />

<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />

<asp:TemplateField HeaderText="dropdown">

<ItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="CustomerName" DataValueField="CustomerID">

</asp:DropDownList>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" FilterExpression="ProductID='{0}'" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParameters>

<asp:ControlParameter Name="Title" DefaultValue="0"/>

</FilterParameters>

</asp:SqlDataSource>

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 4506
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*********@studio-moderna.com> wrote in message news:eJ**************@tk2msftngp13.phx.gbl...
In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1">

<Columns>

<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" />

<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />

<asp:TemplateField HeaderText="dropdown">

<ItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="CustomerName" DataValueField="CustomerID">

</asp:DropDownList>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" FilterExpression="ProductID='{0}'" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParameters>

<asp:ControlParameter Name="Title" DefaultValue="0"/>

</FilterParameters>

</asp:SqlDataSource>

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**************@TK2MSFTNGP11.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*********@studio-moderna.com> wrote in message news:eJ**************@tk2msftngp13.phx.gbl...
In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1">

<Columns>

<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" />

<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />

<asp:TemplateField HeaderText="dropdown">

<ItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="CustomerName" DataValueField="CustomerID">

</asp:DropDownList>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" FilterExpression="ProductID='{0}'" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParameters>

<asp:ControlParameter Name="Title" DefaultValue="0"/>

</FilterParameters>

</asp:SqlDataSource>

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*********@studio-moderna.com> wrote in message news:%2****************@TK2MSFTNGP09.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**************@TK2MSFTNGP11.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*********@studio-moderna.com> wrote in message news:eJ**************@tk2msftngp13.phx.gbl...
In gridView I have dropdown list :

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ProductID" DataSourceID="SqlDataSource1">

<Columns>

<asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False"ReadOnly="True" SortExpression="ProductID" />

<asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" />

<asp:TemplateField HeaderText="dropdown">

<ItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource2" DataTextField="CustomerName" DataValueField="CustomerID">

</asp:DropDownList>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductID], [ProductName] FROM [Alphabetical list of products]"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" FilterExpression="ProductID='{0}'" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [CustomerName], [CustomerID] FROM [Invoices] " >

<FilterParameters>

<asp:ControlParameter Name="Title" DefaultValue="0"/>

</FilterParameters>

</asp:SqlDataSource>

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
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...
8
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...
3
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...
2
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...
5
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,...
2
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...
0
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...
2
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 /> ...
8
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.