Click here to Skip to main content
15,922,533 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ASP.Net caching problem Pin
Parwej Ahamad10-Jan-08 19:35
professionalParwej Ahamad10-Jan-08 19:35 
GeneralRe: ASP.Net caching problem Pin
N a v a n e e t h10-Jan-08 17:57
N a v a n e e t h10-Jan-08 17:57 
GeneralJump to another ASPX page and run its class function of that ASPX page. Pin
VinothRao10-Jan-08 17:19
VinothRao10-Jan-08 17:19 
GeneralRe: Jump to another ASPX page and run its class function of that ASPX page. Pin
Parwej Ahamad10-Jan-08 18:02
professionalParwej Ahamad10-Jan-08 18:02 
GeneralRe: Jump to another ASPX page and run its class function of that ASPX page. Pin
N a v a n e e t h10-Jan-08 18:07
N a v a n e e t h10-Jan-08 18:07 
GeneralInsert images in to MySql database Pin
yadlaprasad10-Jan-08 9:13
yadlaprasad10-Jan-08 9:13 
GeneralRe: Insert images in to MySql database Pin
Pete O'Hanlon10-Jan-08 11:01
mvePete O'Hanlon10-Jan-08 11:01 
GeneralSomething broke (DataBind Gone Wild) Pin
Todd Smith10-Jan-08 8:18
Todd Smith10-Jan-08 8:18 
Sometime within the last week some code broke which I'm pretty sure hasn't changed. It's a simple DropDownList bound to a Country table in the database.

The data in the table hasn't changed. The code for that page hasn't changed. The web.config hasn't changed. And all the other pages which talk to the DB work. If I checkout the codebase and get it running on my home system it works including the DropDownList with countries.

here's the offending code snippet

<br />
IDataReader dr = DB.GetRS("select * from Country " + DB.GetNoLock() + " where Published = 1 order by DisplayOrder,Name");<br />
BillingCountry.DataSource = dr;<br />
BillingCountry.DataTextField = "Name";<br />
BillingCountry.DataValueField = "Name";<br />
BillingCountry.DataBind();<br />
dr.Close();<br />
BillingCountry.SelectedIndex = 0;<br />


the simple markup
<br />
<asp:DropDownList ID="BillingCountry" runat="server" OnSelectedIndexChanged="BillingCountry_OnChange" AutoPostBack="True"></asp:DropDownList><br />


the query implementation

<br />
static public IDataReader GetRS(String Sql)<br />
{<br />
    SqlConnection dbconn = new SqlConnection();<br />
    dbconn.ConnectionString = DB.GetDBConn();<br />
    dbconn.Open();<br />
    SqlCommand cmd = new SqlCommand(Sql, dbconn);<br />
    return cmd.ExecuteReader(CommandBehavior.CloseConnection);<br />
}<br />


and the error it produces

<br />
'BillingCountry' has a SelectedValue which is invalid because it does not exist in the list of items.<br />
Parameter name: value <br />
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br />
<br />
Exception Details: System.ArgumentOutOfRangeException: 'BillingCountry' has a SelectedValue which is invalid because it does not exist in the list of items.<br />
Parameter name: value<br />
<br />
Source Error: <br />
Line 442:                BillingCountry.DataTextField = "Name";<br />
Line 443:                BillingCountry.DataValueField = "Name";<br />
Line 444:                BillingCountry.DataBind();<br />
Line 445:                dr.Close();<br />
Line 446:                BillingCountry.SelectedIndex = 0;<br />


It's throwing the exception on the call to DataBind().

The odd part is that it says the SelectedValue doesn't exist in the list of items yet its looking for the item "United States" which it got from the database! Here's a SS of the results returned by the above query country.jpg[^].

At this point I assume its some DB related component on my system that's gone bad but I'm not too familiar with the inner workings enough to know what to look into. Any suggestions on what to look at / reinstall / uninstall? Have any of the recent MS updates affected the components involved here?

Todd Smith

GeneralRe: Fixed Pin
Todd Smith10-Jan-08 9:33
Todd Smith10-Jan-08 9:33 
QuestionEnterprise library throws exception once a day: Invalid operation. The connection is closed Pin
HappyASPNETCoding10-Jan-08 7:46
HappyASPNETCoding10-Jan-08 7:46 
GeneralRe: Enterprise library throws exception once a day: Invalid operation. The connection is closed Pin
Pete O'Hanlon10-Jan-08 10:32
mvePete O'Hanlon10-Jan-08 10:32 
GeneralRe: Enterprise library throws exception once a day: Invalid operation. The connection is closed Pin
HappyASPNETCoding11-Jan-08 9:35
HappyASPNETCoding11-Jan-08 9:35 
GeneralMy ASP.NET DataGrid is not showing up in web page [modified] Pin
dyerstein10-Jan-08 7:02
dyerstein10-Jan-08 7:02 
QuestionUsing Outlook tasks and calendar in my ASP net web application Pin
Member 475670910-Jan-08 5:46
Member 475670910-Jan-08 5:46 
Generalcss styles Pin
solarthur0110-Jan-08 4:32
solarthur0110-Jan-08 4:32 
Generalgridview problem Pin
solarthur0110-Jan-08 3:02
solarthur0110-Jan-08 3:02 
GeneralRe: gridview problem Pin
Declan Bright10-Jan-08 3:06
Declan Bright10-Jan-08 3:06 
GeneralRe: gridview problem Pin
solarthur0110-Jan-08 3:19
solarthur0110-Jan-08 3:19 
GeneralCreate Image from html string Pin
Imran Khan Pathan10-Jan-08 1:29
Imran Khan Pathan10-Jan-08 1:29 
GeneralRe: Create Image from html string Pin
N a v a n e e t h10-Jan-08 1:35
N a v a n e e t h10-Jan-08 1:35 
GeneralRe: Create Image from html string Pin
Imran Khan Pathan10-Jan-08 1:56
Imran Khan Pathan10-Jan-08 1:56 
GeneralRe: Create Image from html string Pin
N a v a n e e t h10-Jan-08 2:06
N a v a n e e t h10-Jan-08 2:06 
GeneralRe: Create Image from html string Pin
Imran Khan Pathan10-Jan-08 2:18
Imran Khan Pathan10-Jan-08 2:18 
GeneralDisplay Msgbox Pin
Rinki Mukheraji10-Jan-08 0:47
Rinki Mukheraji10-Jan-08 0:47 
GeneralRe: Display Msgbox Pin
Declan Bright10-Jan-08 1:13
Declan Bright10-Jan-08 1:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.