Custom field, WebBBS and AspxGridView - Column is not exist


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
This looks to be a very simple problem.  Your code is a bit confusing as you are creating a new BO instance inside of the BO you are referencing.  So this is a bit confusing.  Secondly, you are seeking inside of the property itself, which again, could cause all types of problems and is definitely not recommended.  Your code should look more like this:

public System.String ApproverCode

{
get
{
Guid id = this.CurrentRow["ApproverId"] == DBNull.Value ? Guid.Empty : (Guid)this.CurrentRow["ApproverId"];

if (id != null)
{
 //-- Obviously you will want to call another internal method.  But you should get the idea.  Calling
 //-- a scalar method would be faster and cleaner than your other code.
 return (string)Me.ExecuteScalar("SELECT code FROM WhateverTable WHERE mycriteria = @mycritera);

}
else
{
 return string.Empty;
}}}

If you can't get it to work, then post a sample that reproduces the problem instead of posting code snippetts.  Thanks.

ChanKK
ChanKK
StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)StrataFrame User (414 reputation)
Group: Forum Members
Posts: 190, Visits: 1.3K
Hi,

I encounter error message when I try to bind a DropDownList in a GridView to a BO Custom Bindable Property.

My Custom Bindable Property in BO:

protected override FieldPropertyDescriptor[] GetCustomBindablePropertyDescriptors()

{

return new FieldPropertyDescriptor[]

{

new ReflectionPropertyDescriptor("ApproverCode", typeof(RouteGroupBO))

};

}

[Browsable(false),

BusinessFieldDisplayInEditor(),

Description("ApproverCode"),

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

public System.String ApproverCode

{

get

{

_approver = new ApproverBO();

Guid id = this.CurrentRow["ApproverId"] == DBNull.Value ? Guid.Empty : (Guid)this.CurrentRow["ApproverId"];

_approver.FillById(id);

if (_approver.MoveFirst())

{

return _approver.ApproverCode;

}

else

{

return string.Empty;

}

}

}

ERROR MESSAGE AT ASPX PAGE (DEBUG MODE):

<ItemTemplate>
   <asp:Label ID="lblApproverCode" runat="server"
   Text='<%# Bind("ApproverCode") %>'></asp:Label>
</ItemTemplate>

DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'ApproverCode'.

 

However, it simply run fine with this.MyBoInstance.MyCustomField. Help...


Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
The only reason that you would get this error is:

  1. You are attempting to access the BO like this: MyBO.Item("MyField") and you do not have a descriptor.  Even still, you would want to pull it from the table like this: MyBO.CurrentRow.Item("MyField")
  2. You do not have a type descriptor as mentioned by Juan

Bill Cunnien
Bill Cunnien
StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)StrataFrame VIP (1.1K reputation)
Group: Forum Members
Posts: 785, Visits: 3.6K
Make sure that your FieldPropertyDescriptors have been defined in your BO, like this:


protected override FieldPropertyDescriptor[] GetCustomBindablePropertyDescriptors()
{
   
return new FieldPropertyDescriptor[]
    {
       
new ReflectionPropertyDescriptor("myCustomField", typeof(MyBO))
   
};
}

Chan
Chan
Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)Advanced StrataFrame User (701 reputation)
Group: Forum Members
Posts: 533, Visits: 2K
Hi,

I have created custom property in my BO, attach it to WebBBS and bind to AspxGridView. I hit error that "Column 'myCustomField' does not exist in System.Data.DataView".



Any ideas? Urgent!



Thank you
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search