webcontrol throws error

Discussion in 'ASP .Net Web Controls' started by Abraham Andres Luna, Sep 27, 2005.

  1. i have a cs file in my app_code directory with the following code:

    using System;
    using System.Web.UI.WebControls;

    namespace RDK.WebControls
    {
    public class DepositTypDropDown : DropDownList
    {
    protected override void OnInit(EventArgs E)
    {
    base.OnInit(E);
    this.Items.Add(new ListItem("Nonrefundable", "NR"));
    this.Items.Add(new ListItem("Refundable", "RE"));
    this.Items.Add(new ListItem("Option to Purchase", "OP"));
    }
    public static string GetText(string strValue)
    {
    DepositTypDropDown ddl = new DepositTypDropDown();
    return ddl.Items.FindByValue(strValue).Text; //this line throws the
    error
    }
    }
    }


    when i try to call the gettext function using:

    lblDepositTyp.Text =
    DepositTypDropDown.GetText(drQuote["DepositTypId"].ToString());

    i get this error:

    Object reference not set to an instance of an object.

    is there another method i have to call after creating a new instance to get
    the list items to be there?
     
    Abraham Andres Luna, Sep 27, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    2
    Views:
    750
  2. Luis Ramírez.

    Can a webcontrol (webcontrol.dll) have a configuration file?

    Luis Ramírez., Jul 5, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    212
    Luis Ramírez
    Jul 6, 2004
  3. Kasabaarde Sumta

    WebControl inside of WebControl and attaching events

    Kasabaarde Sumta, Dec 13, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    207
    Kasabaarde Sumta
    Dec 13, 2004
  4. Fabricio

    Custom webcontrol that references another webcontrol

    Fabricio, Sep 21, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    197
    Fabricio
    Sep 21, 2005
  5. Peter Morris [Air Software Ltd]

    WebControl with non-WebControl property

    Peter Morris [Air Software Ltd], Dec 7, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    144
    Peter Morris [Air Software Ltd]
    Dec 7, 2004
Loading...

Share This Page