How to create a datatype which displays Node names in dropdown?
Hi all,
Below i m creating a dropdown datatype which reads the Nodes and populates the dropdown.
Please check my code and tell me where i m doing wrong because i'm getting Null reference exception error
using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using umbraco.presentation.nodeFactory;
public partial class EditAdminUser : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor { protected string umbracoValue; protected void Page_Load(object sender, EventArgs e) { Fill_DD_Category(); } public object value { get { return umbracoValue; } set { umbracoValue = value.ToString(); } } public void Fill_DD_Category() { DataTable dt1 = new DataTable(); dt1.Columns.Add(new DataColumn("nodeName", typeof(string))); dt1.Columns.Add(new DataColumn("nodeID", typeof(string))); DataRow dr; dr = dt1.NewRow(); dr["nodeName"] = "Please select category"; dr["nodeID"] = "0"; dt1.Rows.Add(dr);
How to create a datatype which displays Node names in dropdown?
Hi all,
Below i m creating a dropdown datatype which reads the Nodes and populates the dropdown.
Please check my code and tell me where i m doing wrong because i'm getting Null reference exception error
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using umbraco.presentation.nodeFactory;
public partial class EditAdminUser : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
{
protected string umbracoValue;
protected void Page_Load(object sender, EventArgs e)
{
Fill_DD_Category();
}
public object value
{
get
{
return umbracoValue;
}
set
{
umbracoValue = value.ToString();
}
}
public void Fill_DD_Category()
{
DataTable dt1 = new DataTable();
dt1.Columns.Add(new DataColumn("nodeName", typeof(string)));
dt1.Columns.Add(new DataColumn("nodeID", typeof(string)));
DataRow dr;
dr = dt1.NewRow();
dr["nodeName"] = "Please select category";
dr["nodeID"] = "0";
dt1.Rows.Add(dr);
Node CurrentNode = Node.GetCurrent();
Nodes nodes = CurrentNode.Children;
foreach (Node node in nodes)
{
dr = dt1.NewRow();
dr["nodeName"] = node.Name;
dr["nodeID"] = node.Id;
dt1.Rows.Add(dr);
}
DD_Category.DataSource = dt1;
DD_Category.DataTextField = "nodeName";
DD_Category.DataValueField = "nodeID";
DD_Category.DataBind();
}
}
---vijay.
Show the complete error message, including the line and you'll probably get a clue of what object is null!
Cheers,
/Dirk
is working on a reply...