webcontrol throws error

  • Thread starter Abraham Andres Luna
  • Start date
A

Abraham Andres Luna

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top