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

intReIssueId is neither a DataColumn nor a DataRelation for table Table.

7 Answers 290 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 18 Apr 2012, 09:10 PM
So I am running into this error after a postback on my radgrid, and I cannot figure out what the heck it is.  so its on teh following command in my radgrid.  So when it initially binds it might have a sub record or not, if they have sub record they have to choice accept it or deny it.  I the follwoing they deny it, which updates a few bits and does a rebind.  But on rebind is when i get the error its like it does not see the record or something.  but if i response.write out all the statements the data is there.


If TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "myReIssueGrid" Then
          If (e.CommandName = "Cancel") Then
              Dim ReIssueId As Integer = e.CommandArgument
              sql = "Execute sp_ReIssueCancel " & ReIssueId & ", " & Convert.ToInt32(HFPersId.Value)
              insertUpdateDelete(sql)
              'FillIssue(HFPersId.Value)
              myIssueGrid.Rebind()
          End If
      End If

after this it should do a rebind
Protected Sub myIssueGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myIssueGrid.NeedDataSource
      sql = "Select dr.strSN, dr.intTranstypeId, dm.strManufacturer + '  ' + mm.strMake + ' - ' + m.strModel Item, tt.strTransaction, i.intIssuedId, CONVERT(varchar(10), i.dtIssued, 111) DT_Issued, " _
         & "p.strFullname + '\' + p.strRank IssuedTo, ftQTY From Drat_Issued i INNER JOIN Drat_Received dr on dr.intRecId = i.intRecId INNER JOIN Drat_TransactionType tt on tt.intTransTypeId = dr.intTransTypeId " _
         & "INNER JOIN Drat_Model m on m.intModelId = dr.intModelID INNER JOIN Drat_Make mm on mm.intMakeId = m.intMakeId INNER JOIN Drat_Manufacturer dm on dm.intManufacturerId = mm.intManufacturerID INNER JOIN " _
         & "MnNgPersonnel.dbo.tblMNNatPersonnel p on p.intPersonnelId = i.intIssuedTo Where bitSigned Is Not NULL And bitTakeOffHR Is NULL And bitTransfer Is NULL and intIssuedto = " & HFPersId.Value & ""
      myIssueGrid.DataSource = getData(sql)
  End Sub

And the following is where its breaking on the bind of the subgrid
Protected Sub myIssueGrid_DetailTableDataBind(sender As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles myIssueGrid.DetailTableDataBind
       If e.DetailTableView.Name = "myReIssueGrid" Then
           sql = "Select ri.intReIssueId, ri.intIssuedId, CONVERT(varchar(10), ri.dtIssue, 111) DT_Issue, intReIssueBy, p.strFullname + '\' + p.strRank IssuedBy, mn.strFullname + '\' + mn.strRank IssuedTo " _
               & "From Drat_ReIssue ri LEFT JOIN Drat_Issued i on i.intIssuedId = ri.intIssuedId LEFT JOIN drat_Received dr on dr.intRecId = i.intRecId LEFT JOIN MnNgPersonnel.dbo.tblMNNatPersonnel p on " _
               & "p.intPersonnelId = ri.intReIssueBy INNER JOIN MnNgPersonnel.dbo.tblMNNatPersonnel mn on mn.intPersonnelId = ri.intReIssueTo Where i.bitReIssue = 1 And ri.bitAccepted Is NULL AND " _
               & "ri.intIssuedId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intIssuedID")
           e.DetailTableView.DataSource = getData(sql)
       End If
   End Sub


error
intReIssueId is neither a DataColumn nor a DataRelation for table Table. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
Exception Details: System.ArgumentException: intReIssueId is neither a DataColumn nor a DataRelation for table Table.
  
Source Error: 
  
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
  
Stack Trace: 
  
  
[ArgumentException: intReIssueId is neither a DataColumn nor a DataRelation for table Table.]
   System.Data.DataRowView.get_Item(String property) +2725340
   Telerik.Web.UI.GridTableView.PopulateDataKeys(Object dataItem) +238
  
[GridException: There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource.]
   Telerik.Web.UI.GridTableView.PopulateDataKeys(Object dataItem) +1220
   Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +431
   Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +161
   Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1450
   Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +858
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +94
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +182
   Telerik.Web.UI.GridTableView.PerformSelect() +206
   Telerik.Web.UI.GridTableView.DataBind() +441
   Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) +2337
   Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) +158
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +50
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
   Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) +102
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3707
  
  

7 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 1
answered on 18 Apr 2012, 09:59 PM
Hello,

So further information, when I do not rebind the grid above in the itemcommand for cancel it does not error out but also the grid does not refresh itself, so it comes down to somehow the whole grid is not refreshing itself and its getting stuck on the sub record detailtabledatabind and errorint out because it can no longer see this record.  But its funny becuae I do the same on teh accept and it works just fine.
0
Maria Ilieva
Telerik team
answered on 20 Apr 2012, 10:35 AM
Hello Kevin,

Could you please try to disable the RadGrid's columns ViewState using the following:
<telerik:RadGrid ...> 
<MasterTableView EnableColumnsViewState="false">
.......
</telerik:RadGrid>

Give this a try and let me know if it works for you. If this doesn;t helps I would suggest you to send us runnable version of your application which demonstrates the presented error. Thus we will be able to debug it locally a nd advise you further.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kevin
Top achievements
Rank 1
answered on 20 Apr 2012, 02:49 PM
HI,

Tried it and it did not work but it produced another error that i had not seen.  Can't send you the Db as the it is made up of 3 different DB's with a lot of personnel information.  All I can do is try to describe what is happening.  I found a work around by redirecting the page to itself.  Basically I have to commands one that accepts a database item and one that rejects it, both get rid of the sub database record mo matter what is just the way its processed in the DB.  The accept command works just fine, bu the cancel command always gives the error.  The latest error is following.  So commandname accept works perfectly fine, but the cancel always throws the error, so I put the redirect in there to get by but it's not the solution.

Error Number and Description: Parent table relations set, but no corresponding data-key name found 
Problem Description: at Telerik.Web.UI.GridTableView.SetDataSourceFilter() at Telerik.Web.UI.GridTableView.FilterDetailDataSource() at Telerik.Web.UI.GridTableView.DataBind() at Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source) at Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at Telerik.Web.UI.GridItem.OnBubbleEvent(Object source, EventArgs e) at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) ----  


If TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "myReIssueGrid" Then
          If (e.CommandName = "Accept") Then
              Dim ReIssueId As Integer = e.CommandArgument
              sql = "Execute sp_AcceptReissue " & ReIssueId & ", " & Convert.ToInt32(HFPersId.Value)
              insertUpdateDelete(sql)
              myIssueGrid.Rebind()
          End If
      End If
      If TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "myReIssueGrid" Then
          If (e.CommandName = "Cancel") Then
              Dim ReIssueId As Integer = e.CommandArgument
              sql = "Execute sp_ReIssueCancel " & ReIssueId & ", " & Convert.ToInt32(HFPersId.Value)
              insertUpdateDelete(sql)
              'myIssueGrid.Rebind() 
                    response.redirect("Issue.aspx")
          End If
      End If

my data satements are as follows.

Protected Sub myIssueGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles myIssueGrid.NeedDataSource
      sql = "Select dr.strSN, dr.intTranstypeId, dm.strManufacturer + '  ' + mm.strMake + ' - ' + m.strModel Item, tt.strTransaction, i.intIssuedId, CONVERT(varchar(10), i.dtIssued, 111) DT_Issued, " _
         & "p.strFullname + '\' + p.strRank IssuedTo, ftQTY From Drat_Issued i INNER JOIN Drat_Received dr on dr.intRecId = i.intRecId INNER JOIN Drat_TransactionType tt on tt.intTransTypeId = dr.intTransTypeId " _
         & "INNER JOIN Drat_Model m on m.intModelId = dr.intModelID INNER JOIN Drat_Make mm on mm.intMakeId = m.intMakeId INNER JOIN Drat_Manufacturer dm on dm.intManufacturerId = mm.intManufacturerID INNER JOIN " _
         & "MnNgPersonnel.dbo.tblMNNatPersonnel p on p.intPersonnelId = i.intIssuedTo Where bitSigned Is Not NULL And bitTakeOffHR IS NULL And bitTransfer Is NULL and intIssuedto = " & HFPersId.Value & ""
        
      myIssueGrid.DataSource = getData(sql)
  End Sub
Protected Sub myIssueGrid_DetailTableDataBind(sender As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles myIssueGrid.DetailTableDataBind
      If e.DetailTableView.Name = "myReIssueGrid" Then
          sql = "Select ri.intReIssueId, ri.intIssuedId, CONVERT(varchar(10), ri.dtIssue, 111) DT_Issue, intReIssueBy, p.strFullname + '\' + p.strRank IssuedBy, mn.strFullname + '\' + mn.strRank IssuedTo " _
              & "From Drat_ReIssue ri LEFT JOIN Drat_Issued i on i.intIssuedId = ri.intIssuedId LEFT JOIN drat_Received dr on dr.intRecId = i.intRecId LEFT JOIN MnNgPersonnel.dbo.tblMNNatPersonnel p on " _
              & "p.intPersonnelId = ri.intReIssueBy INNER JOIN MnNgPersonnel.dbo.tblMNNatPersonnel mn on mn.intPersonnelId = ri.intReIssueTo Where i.bitReIssue = 1 And ri.bitAccepted Is NULL AND " _
              & "ri.intIssuedId = " & e.DetailTableView.ParentItem.GetDataKeyValue("intIssuedID")
          e.DetailTableView.DataSource = getData(sql)
      End If
  End Sub




0
Kevin
Top achievements
Rank 1
answered on 20 Apr 2012, 02:50 PM
here is my full grid.

<telerik:RadGrid ID="myIssueGrid" runat="server" Width="95%" BorderWidth="1px" CellPadding="6" GridLines="None" BorderColor="#404040" Skin="Web20">
                                            <MasterTableView AutoGenerateColumns="false" DataKeyNames="intIssuedID" HierarchyDefaultExpanded="false" HierarchyLoadMode="Client" Name="MasterGrid" EnableColumnsViewState="false"
                                                BorderColor="#404040" Font-Size="10" Font-Names="Veranda,arial,sans-serif" HeaderStyle-HorizontalAlign="Center" NoMasterRecordsText="No Items on iDRAT Hand Receipt"
                                                GridLines="Both" BorderWidth="1px" ExpandCollapseColumn-ButtonType="ImageButton" ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" 
                                                ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png"><ItemStyle HorizontalAlign="Center" />
                                                <AlternatingItemStyle BackColor="#B0C4DE"  HorizontalAlign="Center" />
                                                <HeaderStyle ForeColor="White" Font-Bold="true" BorderColor="#404040" BorderWidth="1px" />
                                                <DetailTables>
                                                    <telerik:GridTableView Name="myReIssueGrid" runat="server" DataKeyNames="intReIssueId" TableLayout="Fixed" BorderWidth="1px" CellPadding="6" Font-Size="10"
                                                        AutoGenerateColumns="False" HeaderStyle-HorizontalAlign="Center" BorderColor="#404040" Font-Names="Veranda,arial,sans-serif" GridLines="Both" ExpandCollapseColumn-ButtonType="ImageButton"
                                                        ExpandCollapseColumn-CollapseImageUrl="~/Images/30.png" ExpandCollapseColumn-ExpandImageUrl="~/Images/29.png">
                                                        <ParentTableRelation>
                                                            <telerik:GridRelationFields DetailKeyField="intIssuedID" MasterKeyField="intIssuedID" />
                                                        </ParentTableRelation>
                                                        <HeaderStyle Font-Bold="true" HorizontalAlign="Center" CssClass="MostInnerHeaderStyle" />
                                                        <ItemStyle CssClass="MostInnerItemStyle" HorizontalAlign="Center" />
                                                        <AlternatingItemStyle CssClass="MostInnerAlernatingItemStyle" HorizontalAlign="Center" />
                                                        <Columns>
                                                            <telerik:GridTemplateColumn HeaderText="Accept" ItemStyle-HorizontalAlign="Center">
                                                                <ItemTemplate>
                                                                     <asp:LinkButton ID="lnkAccept" runat="server" CommandArgument='<%# bind("intReIssueId") %>' CommandName="Accept" Text="Accept"></asp:LinkButton>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridTemplateColumn HeaderText="Cancel" ItemStyle-HorizontalAlign="Center">
                                                                <ItemTemplate>
                                                                     <asp:LinkButton ID="lnkCancel" runat="server" CommandArgument='<%# bind("intReIssueId") %>' CommandName="Cancel" Text="Not Returned"></asp:LinkButton>
                                                                      <asp:Label ID="lbltrans" runat="server" Text='<%# bind("intReIssueBy") %>' Visible="false"></asp:Label>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridBoundColumn DataField="IssuedBy" HeaderText="ISSUED FROM" ItemStyle-Font-Size="Smaller" />
                                                            <telerik:GridBoundColumn DataField="IssuedTo" HeaderText="ISSUED TO"  ItemStyle-Font-Size="Smaller" />
                                                            <telerik:GridBoundColumn DataField="DT_Issue" HeaderText="DT_ISSUED" />
                                                        </Columns>
                                                    </telerik:GridTableView>
                                                </DetailTables>
                                                 <Columns>
                                                     <telerik:GridTemplateColumn HeaderText="Transfer" ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                                <asp:LinkButton ID="lnkTransfer" runat="server" CommandArgument='<%# bind("intIssuedID") %>' CommandName="Transfer">
                                                                <asp:Image ID="imgTransfer" runat="server" ImageUrl="~/Images/Transfer.png"  BorderStyle="None" />
                                                                </asp:LinkButton>
                                                                <asp:Label ID="lbltranstype" runat="server" Text='<%# bind("intTranstypeId") %>' Visible="false"></asp:Label>
                                                        </ItemTemplate>
                                                    </telerik:GridTemplateColumn>
                                                    <telerik:GridBoundColumn HeaderText="SN" DataField="strSN" />
                                                    <telerik:GridBoundColumn HeaderText="STATUS" DataField="strTransaction" />
                                                    <telerik:GridBoundColumn HeaderText="EQUIPMENT" DataField="Item" />
                                                    <telerik:GridBoundColumn HeaderText="DT_ISSUED" DataField="DT_Issued" />
                                                    <telerik:GridBoundColumn HeaderText="QTY" DataField="ftQTY" />
                                                </Columns>
                                            </MasterTableView>
                                        </telerik:RadGrid>
0
Maria Ilieva
Telerik team
answered on 25 Apr 2012, 11:16 AM
Hello Kevin,

Could you please try to call

e.Canceled = true

 in the ItemCommand event for "Cancel" command and verify if this makes any deference.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Kevin
Top achievements
Rank 1
answered on 25 Apr 2012, 09:26 PM
Hi,
Ok, i put the follwoing into the code an the page did not rebind itself, it just cleared the record and sat there.

If TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "myReIssueGrid" Then
          If (e.CommandName = "Cancel") Then
              Dim ReIssueId As Integer = e.CommandArgument
              sql = "Execute sp_ReIssueCancel " & ReIssueId & ", " & Convert.ToInt32(HFPersId.Value)
              insertUpdateDelete(sql)
              If e.Canceled = True Then
                  myIssueGrid.Rebind()
              End If
              'myIssueGrid.Rebind()
              'Response.Redirect("Issue.aspx")
          End If
      End If

<Columns>
                                                           <telerik:GridTemplateColumn HeaderText="Accept" ItemStyle-HorizontalAlign="Center">
                                                               <ItemTemplate>
                                                                    <asp:LinkButton ID="lnkAccept" runat="server" CommandArgument='<%# bind("intReIssueId") %>' CommandName="Accept" Text="Accept"></asp:LinkButton>
                                                               </ItemTemplate>
                                                           </telerik:GridTemplateColumn>
                                                           <telerik:GridTemplateColumn HeaderText="Cancel" ItemStyle-HorizontalAlign="Center">
                                                               <ItemTemplate>
                                                                    <asp:LinkButton ID="lnkCancel" runat="server" CommandArgument='<%# bind("intReIssueId") %>' CommandName="Cancel" Text="Not Returned"></asp:LinkButton>
                                                                     <asp:Label ID="lbltrans" runat="server" Text='<%# bind("intReIssueBy") %>' Visible="false"></asp:Label>
                                                               </ItemTemplate>
                                                           </telerik:GridTemplateColumn>
0
Maria Ilieva
Telerik team
answered on 02 May 2012, 08:08 AM
Hello,

In order to close the form and rebind d the RadGrid control please try to use the following:

If TypeOf e.Item Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "myReIssueGrid" Then 
          If (e.CommandName = "Cancel") Then 
              Dim ReIssueId As Integer = e.CommandArgument 
              sql = "Execute sp_ReIssueCancel " & ReIssueId & ", " & Convert.ToInt32(HFPersId.Value) 
              insertUpdateDelete(sql) 
              If e.Canceled = True Then 
                 myIssueGrid.MasterTableView.IsItemInserted = false
                  myIssueGrid.Rebind() 
              End If 
              'myIssueGrid.Rebind() 
              'Response.Redirect("Issue.aspx") 
          End If 
      End If



Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or