This is a migrated thread and some comments may be shown as answers.

RadGrid Guid Parsing Issue

4 Answers 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevon Hayes
Top achievements
Rank 1
Kevon Hayes asked on 08 Jul 2014, 01:14 PM
I have a RadGrid hooked up to an objectdatasource, which pulls records with a GUID as it's Primary Key.  Whenever I do an update on the RadGrid I get a parse error and it shows the Guid prefixed with the PKey column name like so:

System.FormatException base Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
"{BoatID:\"280f5da9-4048-4569-9e8c-c3aea971b45e\"}"  I'm not sure why it's prefixing the GUID value w/BoatID.  I can see why it cannot parse this value.  I'm not sure how to fix this since Telerik handles the parsing behind the scences.

Info that may help:
<asp:ObjectDataSource ID="DataSource" runat="server"<br>                     <br>                    TypeName="MyNS.SomeClass.SomeMethod" <br><br>UpdateMethod="UpdateBoat"<br> ><br>             <UpdateParameters><br>                        <asp:Parameter Name="name" Type="String" /><br>                        <asp:Parameter Name="boatId" DbType="Guid" /><br>                    </UpdateParameters><br>                </asp:ObjectDataSource><br><telerik:RadGrid ID="BoatGrid"<br>                AllowAutomaticUpdates="True"<br>                AllowAutomaticInserts="True"<br>                AllowAutomaticDeletes="True"<br>                AllowSorting="True"<br>                AllowPaging="True"<br>                PageSize="5"<br>                AllowMultiRowEdit="False"<br>                EnableViewState="true"<br>                runat="server"<br>                DataSourceID="DataSource"<br>                OnItemDataBound="BoatGrid_ItemDataBound"<br>                OnItemCreated="BoatGrid_ItemCreated"<br>                OnItemUpdated="BoatGrid_ItemUpdated"<br>                OnItemDeleted="BoatGrid_ItemInserted" CellSpacing="-1"<br>                GridLines="Both"><br><Columns><br>                <MasterTableView DataSourceID="accountDataSource" CommandItemDisplay="Top" DataKeyNames="BoatID" ><br><telerik:GridClientSelectColumn ColumnGroupName="tstSelect"><br><br>                        </telerik:GridClientSelectColumn><br>                        <telerik:GridBoundColumn HeaderText="Name" DataField="Name" FilterControlAltText="Filter Name column" SortExpression="Name" UniqueName="Name"><br><br>                            <ColumnValidationSettings><br>                                <ModelErrorMessage Text=""></ModelErrorMessage><br>                            </ColumnValidationSettings><br><br>                        </telerik:GridBoundColumn><br>                        <telerik:GridBoundColumn HeaderText="BoatID" ReadOnly="true" Display="false" DataField="BoatID" DataType="System.Guid" FilterControlAltText="Filter BoatID column" SortExpression="BoatID" UniqueName=BoatID"><br>                        </telerik:GridBoundColumn><br></Columns><br>            </telerik:RadGrid>

4 Answers, 1 is accepted

Sort by
0
Kevon Hayes
Top achievements
Rank 1
answered on 08 Jul 2014, 01:18 PM
I know the datasource in mastertableview doesn't match... I had missed that one as I had to change some things to make it available to the public
0
Angel Petrov
Telerik team
answered on 11 Jul 2014, 08:55 AM
Hi Kevon,

Actually the grid should not add a prefix to the value. Could you please ensure that there is no additional server-side logic that adds the BoatID prefix? Additionally please try subscribing to the OnInsertCommand event and inspect the value in the insert item. For that purpose you can use the below provided code.

C#:
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
    {
        Hashtable table=new Hashtable();
         (e.Item as GridEditFormInsertItem).ExtractValues(table);
        string guidValue=table["BoatID"].ToString();
    }

If the guidValue contains the unwanted prefix I would kindly like to ask you to share with us the entire markup and code-behind of the page so we could further research the matter.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Kevon Hayes
Top achievements
Rank 1
answered on 14 Jul 2014, 07:29 PM
Thanks Angel... I'm assuming this event fires before the actual objectdatasource insert method is called?  Also I'm sure I'm not prefixing the value... only storing the value as a cookie and will I pull the value from the cookie it appears that way.  I'll check the format as described in your post and report back.  Thanks.
0
Angel Petrov
Telerik team
answered on 17 Jul 2014, 10:51 AM
Hello Kevon,

You are correct the event is fired before the actual insert in the database. Please check the format and let us know if the unwanted prefix is added by the RadGrid control.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Kevon Hayes
Top achievements
Rank 1
Answers by
Kevon Hayes
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or