Re: I'm missing something simple
From: Kevin Spencer (kspencer_at_takempis.com)
Date: 05/20/04
- Next message: freekamel: "interop excel print"
- Previous message: mike parr: "button click event being called twice on click"
- In reply to: ccurvey: "I'm missing something simple"
- Next in thread: ccurvey: "Re: I'm missing something simple"
- Reply: ccurvey: "Re: I'm missing something simple"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 20 May 2004 11:25:25 -0400
The following URL should be helpful with your sequence issue:
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"ccurvey" <anonymous@discussions.microsoft.com> wrote in message
news:2DABD5BC-1627-41E0-AADE-1FDAE842FE4B@microsoft.com...
> Hi folks,
>
> This must be really obvious and a newbie mistake. When I load the page
listed below, it works fine. If I change a value in the drop-down, I get "
System.NullReferenceException: Object reference not set to an instance of an
object."
>
> I'm confused because the stack trace seems to imply that the error is on
the function definition for "ddlBooks_SelectedIndexChanged(Object
source)...." But if I take out the line about lblMsg.Text="Placeholder for
book name" and replace it with anything else, the page works (or at least it
doesn't error out). And the stranger part is that if I put something in for
the label in the Page_Load function, then the page won't even load properly.
>
> Any help appreciated.
>
> <%@ Page inherits="BindingDemo" src="BindingDemo.cs" %><html><body><form
runat="server"><table><tr><td>Book</td><td><asp:DropDownList id="ddlBooks"
runat="server" autoPostBack="true"
>
onSelectedIndexChanged="ddlBooks_SelectedIndexChanged"></asp:DropDownList></
td></tr></table><asp:Label name="lblMsg" runat="server"
Text=""/></form></body></html>
>
>
> using System;
> using System.Web;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Collections;
>
> public class BindingDemo : Page
> {
> protected DropDownList ddlBooks;
> protected Label lblMsg;
>
> private void Page_Load (Object sender, EventArgs e)
> {
> if (! IsPostBack)
> {
> ArrayList bookList = new ArrayList();
> bookList.Add("Programming ASP.NET");
> bookList.Add("Programming C#");
> bookList.Add("Teach Yourself C++ In 21 days");
> bookList.Add("C++ Unleashed");
> bookList.Add("XML From Scratch");
>
> ddlBooks.DataSource = bookList;
> ddlBooks.DataBind();
>
> //lblMsg.Text = "You have not picked a book";
> }
> }
>
> protected void ddlBooks_SelectedIndexChanged (Object Source, EventArgs e)
> {
> lblMsg.Text = "Placeholder for book name";
> }
> }
- Next message: freekamel: "interop excel print"
- Previous message: mike parr: "button click event being called twice on click"
- In reply to: ccurvey: "I'm missing something simple"
- Next in thread: ccurvey: "Re: I'm missing something simple"
- Reply: ccurvey: "Re: I'm missing something simple"
- Messages sorted by: [ date ] [ thread ]