2
protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    DataTable dt = GetList();
                    ddldeedno.DataSource = dt;
                    ddldeedno.DataTextField = "DeedNo";
                    ddldeedno.DataValueField = "DeedNo";
                    ddldeedno.DataBind();
                }
                catch (Exception ex)
                {
                    ex.Message.ToString();
                }
            }

        }

        private DataTable GetList()
        {
            SPSite site = new SPSite(SPContext.Current.Web.Url);
            SPWeb web = site.OpenWeb();
            SPList list = web.Lists.TryGetList("Land General Info");

            return list.Items.GetDataTable();

        }

When i use that above code its throwing an exception that "DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'DeedNo'." in sharepoint But there is an attribute name as DeedNo in "Land General Info" list. I don't find out any solution. Please help me to resolve this issue.

Thanks in advance.

1 Answer 1

0

Your code works fine based on my testing, make sure the filed internal name is DeedNo.

var list = web.Lists.TryGetList("Time");
            DataTable dt = list.Items.GetDataTable();
            ddldeedno.DataSource = dt;
            ddldeedno.DataTextField = "DeedNo";
            ddldeedno.DataValueField = "DeedNo";
            ddldeedno.DataBind();

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.