Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 15th, 2005, 09:14 AM
Registered User
 
Join Date: Oct 2005
Location: Coventry, Warwickshire, United Kingdom.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default SqlDatasource filter using formview control

Hi there.

I am a newbie :), and am struggling with a formview problem.

Basically I have created a webform with an SQLDataSource that lists three values, an ID field (integer), URL field (Text) and description field. This is Querying a SQL table called "Images"

I have a FormView (FormView1) on the page, which is bound to another sqlDatasource (table "Pages"), one field of which is an ID field relating to an Image in the Images Table.

I have a List Control within the form view which displays a list of Image Discriptions from the first table, and returns the ID as its selected value.

I also have a gridview with a single ImageField sourced from a third SqlDataSource which is essentially the IMAGES table, filtered by a Listcontrol's selected item, this datasource supplies the actual physical url to the image file associated with a particular ID, that the GridView uses to display the image.

If I use a ListControl OUTSIDE the form view, each time I select an image, it is displayed in the Formview.

However, what I want to do is have the drop down list as a template control within the formview.

When I do this, and try to configure the datasource, I am unable to apply the "WHERE" filter to the SQL, either by using "control" as the templated form control is not displayed in the drop down list, OR by selecting form and enetering something like:

Ctype(Me.FormView1.FindControl("SelectImageListBox "),ListControl.SelectedValue.ToString Where "SelectImageListBox" is the name/ID of the ListBox control within the formview.

Basically I want to access a Formview's templated controls selected value and use it to filter an SqlDataSource

I would be very greatful for any help!

Many Thanks,

Tony:)



 
Old October 15th, 2005, 12:01 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I might be a bit thick, but I had trouble understanding your question. Somehow, I can't see how this page will look like and what you're trying to accomplish.

Can you describe the structure of your page in more detail and maybe post some code?

Is the CType code what you're using right now or did you just type that in? You're missing an additional )

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 17th, 2005, 05:55 AM
Registered User
 
Join Date: Oct 2005
Location: Coventry, Warwickshire, United Kingdom.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the quick reply.

Basically what I was tring to do was to get a List control within a formview to filter the data from an SQLDataSource, and then use the filtered data to bind a url to an Image in a gridview within the form.

Since I could find no way of referencing the formview control when configuring the sqldatasource, I was stuck.

I have worked around by using the list control in the formview to set a value into a hidden field (using its onclick event), outside of the formview, and used this as the filter criteria for the SQLDatasource. It all works fine now :)

Thanks once again.

Tony





Similar Threads
Thread Thread Starter Forum Replies Last Post
FormView Control lokraj ASP.NET 2.0 Basics 0 September 11th, 2007 08:51 AM
Need help with SqlDataSource control binici ASP.NET 2.0 Basics 1 February 5th, 2007 05:32 PM
SqlDataSource control error binici ASP.NET 2.0 Basics 1 January 19th, 2007 08:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.