G
Guest
I am trying to assign a value from DataItem to a variable but keeping getting "
Object reference not set to an instance of an object" error message.
what i am missing?
public void create_ddl(object s, RepeaterItemEventArgs e)
{
string categoryName =
((DataRowView)e.Item.DataItem).Row["FaultDesc"].ToString();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DropDownList dd = (DropDownList)e.Item.FindControl("ddl");
if(dd !=null)
{
dd.DataSource = bs.drPriority();
dd.DataTextField = "text";
dd.DataValueField = "value";
dd.DataBind();
dd.Items.FindByValue(dr["Priority"].ToString()).Selected
= true;
}
}
}
Object reference not set to an instance of an object" error message.
what i am missing?
public void create_ddl(object s, RepeaterItemEventArgs e)
{
string categoryName =
((DataRowView)e.Item.DataItem).Row["FaultDesc"].ToString();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DropDownList dd = (DropDownList)e.Item.FindControl("ddl");
if(dd !=null)
{
dd.DataSource = bs.drPriority();
dd.DataTextField = "text";
dd.DataValueField = "value";
dd.DataBind();
dd.Items.FindByValue(dr["Priority"].ToString()).Selected
= true;
}
}
}