By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

Filter SQLdataSource

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.