![]() |
webcontrol throws error
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? |
| All times are GMT. The time now is 04:36 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.