WinGrid issues

Posts   
 
    
he00273
User
Posts: 133
Joined: 02-Oct-2008
# Posted on: 02-Jun-2009 05:07:32   

****I have a Infragistics UltraWinGrid bound to an EntityCollection.

If I insert a new row and do a adaptor.SaveEntityCollection(EntityCollection);

The changes are persisted to the database (SQL Server). The Infragistics grid however after this shows all the columns for the new row as blanks except the primary key. I am not sure if this is an LLBLGen Pro artifact or a Infragistics UltraWinGriud artificat

Currently to fix this I just refetch a new entitycollection and bind this to the Grid. Is this what one should do or is there a better way? If I delelete tye contents of a nullable string column, I get this error

Unable to update the data value: Object of type 'System.DBNull' cannot be converted to type 'System.String'.

How does one fix this.

Also If i add more characters than is allowed into a string column I get an overlength error

Unable to update the data value: The value specified will cause an overflow error in the database. Value length: 4. Column max. length: 3

I can easily stop this if I can get the metadata about the entity field in question, namely the length value.

I have looked at the entity class generated by LLBLGen Pro and for a property I can see in comments

    /// <summary> The CaseTypeDescription property of the Entity CaseType<br/><br/>
    /// </summary>
    /// <remarks>Mapped on  table field: "CaseType"."CaseTypeDescription"<br/>
    /// Table field type characteristics (**type, precision, scale, length**): NVarChar, 0, 0, 50<br/>
    /// Table field behavior characteristics (is nullable, is PK, is identity): false, false, false</remarks>
    public virtual System.String CaseTypeDescription
    {
        get { return (System.String)GetValue((int)CaseTypeFieldIndex.CaseTypeDescription, true); }
        set { SetValue((int)CaseTypeFieldIndex.CaseTypeDescription, value); }
    }

How can I retrieve this metadata from within my application?

he00273
User
Posts: 133
Joined: 02-Oct-2008
# Posted on: 02-Jun-2009 06:03:17   

From using Intellisense, I have found EntityFields (in my case CaseTypeFields) which gives me the meta data I need.

he00273
User
Posts: 133
Joined: 02-Oct-2008
# Posted on: 02-Jun-2009 06:16:42   

That worked great for restricting the length of data users can enter.

However If I delete the fields contents, I still get

Unable to update the data value: Object of type 'System.DBNull' cannot be converted to type 'System.String'.

he00273
User
Posts: 133
Joined: 02-Oct-2008
# Posted on: 02-Jun-2009 07:18:17   

Had a look on the forums (its hard to search these and find what you want at times).

Found a few suggestions that would not work with intellisense. Maybe these were for an older version of LLBLGen Pro.

Changed the settings in my code that changes the UltraWinGrid after binding to the LLBlGen Pro entity Collection.

I now have

               case "Notes":
                   GridColumn.Header.Caption = "Notes";
                   GridColumn.MaxLength = CaseTypeFields.Notes.MaxLength;
                   GridColumn.MinLength = 0;
                   if (CaseTypeFields.Notes.IsNullable)
                       GridColumn.Nullable = Nullable.Nothing;
                   break;

Which sets the field in the database to a null. (which is what I want). I can use Nullable.EmptyString; which sets it an empty string.

Now all I want is an answer to

If I insert a new row and do a adaptor.SaveEntityCollection(EntityCollection);

The changes are persisted to the database (SQL Server). The Infragistics grid however after this shows all the columns for the new row as blanks except the primary key. I am not sure if this is an LLBLGen Pro artifact or a Infragistics UltraWinGriud artificat

Currently to fix this I just refetch a new entitycollection and bind this to the Grid. Is this what one should do or is there a better way?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Jun-2009 08:58:59   

Pleasue debug this and check if the values are there inside the entityCollection bound to the grid (after the save). If so then it must be an issue of the UltraWebGrid. As this is working with other grids (MS default Grid for example).

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 02-Jun-2009 21:01:50   

A lot of grids have a Rebind or Refetch method to force them to refresh the display - is there something similar on your grid ?

he00273
User
Posts: 133
Joined: 02-Oct-2008
# Posted on: 03-Jul-2009 10:23:06   

I have been distracted elsewhere. I will follow up your suggestions when I get a spare moment. flushed

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 03-Jul-2009 10:42:29   

I'll close this thread for now, and when you reply, it will be automatically re-opened.