Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
|
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 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 May 11th, 2009, 12:01 AM
Registered User
 
Join Date: Feb 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default Updating a SQL DataSource from the code behind?

I have some code in the front end ASPX page that uses several SQL Datasources to populate several dropdownlists and SELECT values from a SQL database based on the SelectedItem Value. (ie the selected value from dropdownlist1 creates a list to populate dropdownlist2, and then that selected value creates a list for dropdownlist3 - the selected value there becomes the critical value for the rest of the code)

I then use DataView objects in the Code Behind to utilize values from additional database tables to perform calculations based on the critical value above. I also can Save some of the selected values from various database tables to another database.

The problem I am trying to resolve is that when I recall the Saved information and try to re-use the values, I dont know how to re-assign the SQL Datasource SelectedItem to the correct value and have the correct DataSource "re-pull" the required information, so to speak.

Is there anyway to do this without re-creating a bunch of SQL connections in the code behind when it seems that the Datasource objects are readily available and just need to be told to "SELECT" the new information?

This is probably confusing and I'm probably not defining the issue correctly, but I am new at this. Any help would be appreciated.

Thanks in advance.
 
Old May 12th, 2009, 09:23 PM
Registered User
 
Join Date: Feb 2009
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default Another Question along the same lines

Or another way to ask this:

Is it possible to re-SELECT items from a SQLDataSource from the code behind? If so, how do I do it?

I tried this in the code behind, where PumpsDS2 is the DataSource ID of the SQLDataSource on the aspx page:

PumpsDS2.SelectCommand = "SELECT * FROM [Pumps] WHERE ([Pump_ID] = @Pump_ID)";
PumpsDS2.SelectParameters.Add("@Pump_ID", pumpID);

PumpsDS2.Select(DataSourceSelectArguments.Empty);

But I get an "Input string was not in a correct format" error in the last line.

Thanks,

Gary





Similar Threads
Thread Thread Starter Forum Replies Last Post
sql datasource with grid view MunishBhatia ASP.NET 2.0 Professional 2 December 13th, 2007 01:13 AM
data is not updating into datasource s_sribardhan ASP.NET 1.0 and 1.1 Basics 1 May 23rd, 2006 04:25 AM
Crystal datasource changing from Access to SQL and tabilda Pro VB 6 4 November 24th, 2005 09:57 AM
Locktype and code for batch updating humour Access VBA 0 August 26th, 2004 08:47 AM





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