Results 1 to 2 of 2

Thread: <dropdownlist>

  1. #1
    Join Date
    Dec 1969

    Default <dropdownlist>

    I am having problems when I try to get the selecteditem.text from the dropdownlist. the below code works fine if enableviewstate=true but when i set it to false i get the following error message.<BR><BR>"System.NullReferenceException: Object reference not set to an instance of an object"<BR><BR>how can i work around this issue without setting the enableviewstate=true.<BR><BR>sub page_load(source as object, e as eventargs)<BR><BR>if not page.ispostback = true then<BR>&#039;i have already opened the connection...etc<BR>ddlSome.Datasource = objCmd<BR>ddlSome.DataBind()<BR>end if<BR><BR>end sub<BR><BR>sub submit_click(source as object, e as eventargs)<BR> response.write(ddlsome.selecteditem.text)<BR>end sub<BR><BR>&#060;form runat=server id=frm&#062;<BR>&#060;asp:dropdownlist runat="server" id="ddlsome" DataTextField="field1" DataValueField="field2" /&#062;<BR>&#060;br/&#062;<BR>&#060;asp:button runat="server" id="btnSubmit" onClick="Submit_Click" /&#062;<BR>&#060;/form&#062;

  2. #2
    Join Date
    Dec 1969

    Default RE: <dropdownlist>

    I believe you need to include the following line in your vb code page<BR>Protected WithEvents ddlsome As System.Web.UI.WebControls.DropDownList<BR><BR>hth< BR>matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts