Selected value not updating detailsview
Let's say, by example, what I have the follow data object:public class Person I created one page with Details View and Object Data Source.I am trying to edit the user image within my Details View using the fileupload control.I am pulling a list of about ten records from a sql server 2000 database table.When I run the page, it works fine (dropdownlist shows the 10 or so items from the database when I click the dropdown button).But now when I run the web page, I get an error indicating the item I am trying to set is not in the list. This will be fired after the data has been binded to dropdownlist.I know the item is in the list coming from the database, but I suspect it is a timing issue - that when I try to set the Selected Value in the Page Load event, the Sql Data Source control has not populated the list for the Drop Down List yet. protected void dl Test_Data Bound(object sender, Event Args e) Thanks The ddl_Data Bound method is exactly what I was looking for except I was looking for something like that on the page not on the individual ddl.When the selected value is not in the list of available values and a postback is performed, an Argument Out Of Range Exception exception is thrown.
It is still in the database and it gets shown in the program if I specifically search for its key.
Details View control is a data-bound control that renders a single record at a time.
For more information, see Themeable Attribute and ASP.
Once I trimmed the value I was setting, it worked fine. The difference is if the code is flawed (as it was before when I really was trying to set a value that was not in the list) I get an error when it is in the Form Load event but if the same code is moved to the ddl. Selected Val, gets the value of the selected item in the list control, or selects the item in the list control that contains the specified value. Find By Text/Value, searches the collection for a List Item with a List Item.
When the page displays, the item I selected in code is actually selected in the ddl! Data Bound method, the error is ignored - no error - the page displays, (but naturally the expected value is not selected). Text/Value property that contains the specified Text/Value.
="DELETE FROM [Customers] WHERE [Customer ID] = @original_Customer ID AND [Company Name] = @original_Company Name AND [Contact Name] = @original_Contact Name AND [Contact Title] = @original_Contact Title AND [Address] = @original_Address AND [City] = @original_City AND [Region] = @original_Region AND [Postal Code] = @original_Postal Code AND [Country] = @original_Country AND [Phone] = @original_Phone AND [Fax] = @original_Fax"="INSERT INTO [Customers] ([Customer ID], [Company Name], [Contact Name], [Contact Title], [Address], [City], [Region], [Postal Code], [Country], [Phone], [Fax]) VALUES (@Customer ID, @Company Name, @Contact Name, @Contact Title, @Address, @City, @Region, @Postal Code, @Country, @Phone, @Fax)"="UPDATE [Customers] SET [Company Name] = @Company Name, [Contact Name] = @Contact Name, [Contact Title] = @Contact Title, [Address] = @Address, [City] = @City, [Region] = @Region, [Postal Code] = @Postal Code, [Country] = @Country, [Phone] = @Phone, [Fax] = @Fax WHERE [Customer ID] = @original_Customer ID AND [Company Name] = @original_Company Name AND [Contact Name] = @original_Contact Name AND [Contact Title] = @original_Contact Title AND [Address] = @original_Address AND [City] = @original_City AND [Region] = @original_Region AND [Postal Code] = @original_Postal Code AND [Country] = @original_Country AND [Phone] = @original_Phone AND [Fax] = @original_Fax"From your description, it almost sounds like the update event is not being fired.