- Home
- LLBLGen Pro
- LLBLGen Pro Runtime Framework
Problem with GUID and dropdowns using ASPxGridView
Joined: 03-Jun-2010
Hi,
Most probably we are missing something. We are using LLBL and ASPxGridView. In GridView we have a combo box column that is supposed to give branches in edit mode. The primary/foreign keys are Guid.
The data binding is working fine. When we go to edit mode we see the values as expected. But when we change a different value, the entity is saving NULL to database and not the correct Guid.
Please note that the problem is in BranchId column.
I have tried changing the cache location to session also as specified elsewhere on this forum but this did not work.
I also tried changing the ValueType="System.String" to ValueType="System.Guid" but still no luck.
This is also not working with CheckBox column IsDisabled which does not has any binding source.
Additionally we also have a Designation column where we are giving the same datasource branchDS but the property is different (type string) and that is correctly providing the value and saving.
So most probably the problem is with Guid. Any clues how I should debug this?
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Display.aspx.cs" Inherits="Display" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v10.1, Version=10.1.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<%@ Register assembly="SD.LLBLGen.Pro.ORMSupportClasses.NET20" namespace="SD.LLBLGen.Pro.ORMSupportClasses" tagprefix="llblgenpro" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
This is Display Page<br />
<llblgenpro:LLBLGenProDataSource2 ID="employeeDS" runat="server"
AdapterTypeName="Aquevix.ContinuaERP.DAL.Company.DatabaseSpecific.DataAccessAdapter, Aquevix.ContinuaERP.DAL.CompanyDBSpecific"
DataContainerType="EntityCollection"
EntityFactoryTypeName="Aquevix.ContinuaERP.DAL.Company.FactoryClasses.EmployeeEntityFactory, Aquevix.ContinuaERP.DAL.Company"
onperformselect="employeeDS_PerformSelect"
onperformwork="employeeDS_PerformWork" CacheLocation="Session">
</llblgenpro:LLBLGenProDataSource2>
<llblgenpro:LLBLGenProDataSource2 ID="branchDS" runat="server"
AdapterTypeName="Aquevix.ContinuaERP.DAL.Company.DatabaseSpecific.DataAccessAdapter, Aquevix.ContinuaERP.DAL.CompanyDBSpecific"
DataContainerType="EntityCollection"
EntityFactoryTypeName="Aquevix.ContinuaERP.DAL.Company.FactoryClasses.BranchEntityFactory, Aquevix.ContinuaERP.DAL.Company" CacheLocation="Session"
>
</llblgenpro:LLBLGenProDataSource2>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="employeeDS" KeyFieldName="EmployeeId"
oncelleditorinitialize="ASPxGridView1_CellEditorInitialize">
<Columns>
<dx:GridViewCommandColumn VisibleIndex="0">
<EditButton Visible="True">
</EditButton>
</dx:GridViewCommandColumn>
<dx:GridViewDataComboBoxColumn FieldName="BranchId" VisibleIndex="1">
<PropertiesComboBox DataSourceID="branchDS" ValueType="System.String" ValueField="BranchId" TextField="ShortName">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataTextColumn FieldName="DepartmentId" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataComboBoxColumn FieldName="Designation" VisibleIndex="3">
<PropertiesComboBox DataSourceID="branchDS" TextField="shortname"
ValueField="shortname" ValueType="System.String">
</PropertiesComboBox>
</dx:GridViewDataComboBoxColumn>
<dx:GridViewDataTextColumn FieldName="EmpCode" VisibleIndex="4">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="EmployeeId" ReadOnly="True"
VisibleIndex="5">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="FirstName" VisibleIndex="6">
</dx:GridViewDataTextColumn>
<dx:GridViewDataCheckColumn FieldName="IsDisabled" VisibleIndex="7">
</dx:GridViewDataCheckColumn>
<dx:GridViewDataTextColumn FieldName="LastName" VisibleIndex="8">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="MiddleName" VisibleIndex="9">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="PersonalEmail" VisibleIndex="10">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ReportsToEmployeeId" VisibleIndex="11">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Title" VisibleIndex="12">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="WorkEmail" VisibleIndex="13">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
<br />
<asp:Label ID="lbl_text" runat="server" Text="Text"></asp:Label>
<asp:Button ID="btn_" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
Just to test, try not to supply a "Type" attribute: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8575 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6914
What is your LLBLGen Runtime Library version? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7720)
Joined: 03-Jun-2010
daelmo wrote:
Just to test, try not to supply a "Type" attribute: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=8575 http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=6914
What is your LLBLGen Runtime Library version? (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7720)
LLBL Runtime Version: 3.0.10.611 OS: WinXP SP3 Visual Studio 2008 SP1 DevExpress 10.5 (Latest) LLBL Designer: July 2, 2010 Database: SQL Server 2005 (full)
That did not help. To further test I did these:
In Employee class where we have a problem
class Employee {
....
/// <summary> The BranchId property of the Entity Employee<br/><br/></summary>
/// <remarks>Mapped on table field: "Employee"."BranchID"<br/>
/// Table field type characteristics (type, precision, scale, length): UniqueIdentifier, 0, 0, 0<br/>
/// Table field behavior characteristics (is nullable, is PK, is identity): true, false, false</remarks>
public virtual Nullable<System.Guid> BranchId
{
get { return (Nullable<System.Guid>)GetValue((int)EmployeeFieldIndex.BranchId, false); }
set { SetValue((int)EmployeeFieldIndex.BranchId, value); }
}
// AQUEVIX:START Added custom properties to test binding problem
public Guid BoundBranchId { get { return this.BranchId.HasValue?this.BranchId.Value:Guid.Empty; } set { this.BranchId = value; } }
public string StringBranchId { get { return this.BranchId.HasValue ? this.BranchId.Value.ToString() : Guid.Empty.ToString(); } set { this.BranchId = new Guid(value); } }
// AQUEVIX:END Added custom properties to test binding problem
}
When I put breakpoint on each set methods, if I am binding with BranchId or BoundBranchId I get a 'value' in set as '0000-000-000000-0000000' (with more zeros) Guid. But when I use StringBranchId I get the correct Guid.
I also checked by directly binding to tables via Sqldatasource in the same grid and all works.
In addition we are also seeing this with boolean fields. One thing to note here is that the fields are NULLABLE.
I have also attached a sample code that shows the problem. Included: SQL script, LLBL files, generated code and Website Project (in VS 2008 ). This uses DevExpress so not sure if you will be able to run this or not.
Anything else I should try next?
Joined: 03-Jun-2010
MTrinder wrote:
We will try to take a look at your attached solution, but cannot guarantee that we will have the DevExpress components available...
Do you get the same behaviour if you use standard windows ASPX components...?
Matt
In the attached solution we have done binding with ASPX grid using A) SqlDataSource and B) LLBL datasource. The SQL data source works fine so I suspect this is not a DevExpress problem.
BTW, This is also happening with SQL Server BIT datatype (boolean) in checkboxes. The value is not getting saved to database.
Can you download a 30 day trial on a test machine and reproduce this? This is a show stopper for us as all our design is using GUIDs. Should I contact LLBL support team via email or file a bug somewhere?
In the attached solution we have done binding with ASPX grid using A) SqlDataSource and B) LLBL datasource. The SQL data source works fine so I suspect this is not a DevExpress problem.
In the mean time could you please test this using MS Grid?
I think it's caused by the way the Guid is specified, as all values are in string format in ASP.NET, and the guid is thus also specified in string format, and has to be converted to a valid value. I think this goes wrong. We'll see if we can reproduce it.
(edit) oh, and please next time add a csproj/sln file, thanks.
(edit) the problem seems to be that the value for BranchId is passed to the datasource control as a 'guid' instead of a string, like everything else. This causes a problem inside the datasourcecontrol, as it expects everything to be a string (as it normally is, all values passed into datasourcecontrols are normally strings with .net asp.net controls)
So we'll add a code path which can handle this properly.
Please use the attached update ormsupportclasses dll. Make sure your project uses this dll. Your test projects were .net 2.0, you might want to update those as well to .net 3.5.
Joined: 03-Jun-2010
Otis wrote:
I think it's caused by the way the Guid is specified, as all values are in string format in ASP.NET, and the guid is thus also specified in string format, and has to be converted to a valid value. I think this goes wrong. We'll see if we can reproduce it.
(edit) oh, and please next time add a csproj/sln file, thanks.
(edit) the problem seems to be that the value for BranchId is passed to the datasource control as a 'guid' instead of a string, like everything else. This causes a problem inside the datasourcecontrol, as it expects everything to be a string (as it normally is, all values passed into datasourcecontrols are strings)
So we'll add a code path which can handle this properly.
Didn't provide a SLN/CSPROJ as this is a website project. Open > Open Website. ;-)
Thanks for the debug. This problem is also seen with Boolean values. I am suspecting some other datatypes may also have this problem.
amitjindal wrote:
Otis wrote:
I think it's caused by the way the Guid is specified, as all values are in string format in ASP.NET, and the guid is thus also specified in string format, and has to be converted to a valid value. I think this goes wrong. We'll see if we can reproduce it.
(edit) oh, and please next time add a csproj/sln file, thanks.
(edit) the problem seems to be that the value for BranchId is passed to the datasource control as a 'guid' instead of a string, like everything else. This causes a problem inside the datasourcecontrol, as it expects everything to be a string (as it normally is, all values passed into datasourcecontrols are strings)
So we'll add a code path which can handle this properly.
Didn't provide a SLN/CSPROJ as this is a website project. Open > Open Website. ;-)
Thanks for the debug. This problem is also seen with Boolean values. I am suspecting some other datatypes may also have this problem.
yes, we added a generic code path for all situations / types, these should be fixed now as well.
Joined: 03-Jun-2010
Otis wrote:
amitjindal wrote:
Otis wrote:
I think it's caused by the way the Guid is specified, as all values are in string format in ASP.NET, and the guid is thus also specified in string format, and has to be converted to a valid value. I think this goes wrong. We'll see if we can reproduce it.
(edit) oh, and please next time add a csproj/sln file, thanks.
(edit) the problem seems to be that the value for BranchId is passed to the datasource control as a 'guid' instead of a string, like everything else. This causes a problem inside the datasourcecontrol, as it expects everything to be a string (as it normally is, all values passed into datasourcecontrols are strings)
So we'll add a code path which can handle this properly.
Didn't provide a SLN/CSPROJ as this is a website project. Open > Open Website. ;-)
Thanks for the debug. This problem is also seen with Boolean values. I am suspecting some other datatypes may also have this problem.
yes, we added a generic code path for all situations / types, these should be fixed now as well.
Works! many thanks!