Click here to Skip to main content
15,909,652 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an error for grid bind.


Gridexception was unhandled by user code
-------------------------------------------------

here was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource.

When I bind the grid I remove 3 fields it is bound successfully, but reminds bind means i got error.

Please, can anyone help ?



thanks,
Karthikeyan




my code:
==========

XML
<%@ Page Title="" Language="C#" MasterPageFile="~/Dialogconsoleheader.master" AutoEventWireup="true"
    CodeFile="PrintLocationStyleDetails.aspx.cs" Inherits="PrintLocationStyleDetails" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ MasterType VirtualPath="~/Dialogconsoleheader.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cphHeader" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server">
    <!-- Header Area Begin -->
    <asp:Table ID="tblDilogHeader" runat="server" Width="100%">
        <asp:TableRow>
            <asp:TableCell>
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
    <!-- Header Area End -->
    <!-- Content Area Begin -->
    <style type="text/css">
        .style1
        {
            font-weight: bold;
            font-size: 9pt;
            color: #ff6600;
            font-family: Arial;
            background-color: #ffdba6;
            height: 12px;
        }
        .RadGrid_Office2007
        {
            font: 11px tahoma,verdana,arial,sans-serif;
        }
        .RadGrid_Office2007
        {
            border: 1px solid #3b5a82;
            background: #fff;
            color: #27413e;
        }
        .MasterTable_Office2007
        {
            border-collapse: separate !important;
        }
        .MasterTable_Office2007
        {
            font: 11px tahoma,verdana,arial,sans-serif;
        }
        .GridHeader_Office2007
        {
            border-left: 1px solid #9eb6ce;
            border-bottom: solid 1px #9eb6ce;
            padding-top: 3px;
            padding-bottom: 2px;
            background: url(          'mvwres://Telerik.Web.UI, Version=2008.3.1125.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4/Telerik.Web.UI.Skins.Office2007.Grid.sprite.gif' ) 0 -200px repeat-x #d3dbe9;
            text-align: left;
            font-size: 12px;
            font-weight: normal;
        }
        .GridHeader_Office2007
        {
            padding-left: 4px;
            padding-right: 4px;
        }
    </style>
    <telerik:RadScriptManager ID="rsmPrintLocationStyle" runat="server">
    </telerik:RadScriptManager>
    <br />
    <asp:HiddenField ID="hdnAction" runat="server" />
    <asp:HiddenField ID="hdnPrintLocationStyleID" runat="server" />
    <table align="center" width="900px" cellspacing="0" cellpadding="0" border="0">
        <tr>
            <td class="cssGeneralPrimaryColorBackground">
                <table width="900px" cellspacing="1" cellpadding="0" border="0">
                    <tr class="cssCardTitle" height="18" align="left">
                        <td class="cssGeneralPrimaryColorBackground">
                            &nbsp; Price Location Styles
                        </td>
                    </tr>
                    <tr>
                        <td width="900px" bgcolor="white" valign="top" align="center">
                            <table cellspacing="1" cellpadding="0" width="880px" border="0">
                                <tr>
                                    <td height="18">
                                        <br />
                                    </td>
                                </tr>
                                <!-- Cost Profile Begin -->
                                <%--<tr>
                                        <td class="cssColHeader" style="width: 880px" height="20">
                                            <b>&nbsp;&nbsp;Cost Profile</b>
                                        </td>
                                    </tr>--%>
                                <%--<tr>
                                        <td align="center">
                                            <table cellspacing="2" cellpadding="2" border="0" style="width: 850px">--%>
                                <tr>
                                    <td>
                                        <telerik:RadGrid ID="rgPrintLocationStyle" runat="server" Width="840px" AutoGenerateColumns="False"
                                                            GridLines="None" Skin="Office2007"
                                            OnItemDataBound="rgPrintLocationStyle_ItemDataBound">
                                                            <HeaderContextMenu EnableTheming="True">
                                                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                                            </HeaderContextMenu>
                                                        <MasterTableView DataKeyNames="PrintLocationStyleId,PrintLocationStyleName,PrintLocationStyleNumOfLocations,PrintLocationStyleLastUpdated,PrintLocationStyleDateCreated">
                                                           <%--<MasterTableView DataKeyNames="PrintLocationStyleId,PrintLocationStyleName">--%>
                                                                <RowIndicatorColumn>
                                                                    <HeaderStyle Width="20px"></HeaderStyle>
                                                                </RowIndicatorColumn>
                                                                <ExpandCollapseColumn>
                                                                    <HeaderStyle Width="20px"></HeaderStyle>
                                                                </ExpandCollapseColumn>
                                                                <Columns>
                                                                    <telerik:GridTemplateColumn HeaderText="Action">
                                                                        <ItemTemplate>
                                                                            <asp:HyperLink ID="lnkEditPrintLocationStyle" runat="server" NavigateUrl="">Edit</asp:HyperLink>
                                                                            |
                                                                            <asp:HyperLink ID="lnkDelPrintLocationStyle" runat="server" NavigateUrl="">Del</asp:HyperLink>
                                                                        </ItemTemplate>
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn HeaderText="Order">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblPrintLocationStyleOrder" runat="server" Text='<%# Eval("PrintLocationStyleId") %>'
                                                                                CssClass="cssField"></asp:Label>
                                                                        </ItemTemplate>
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn HeaderText="Style Name">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblPrintLocationStyleName" runat="server" Text="" DataField="PrintLocationStyleName" ></asp:Label>
                                                                        </ItemTemplate>
                                                                    </telerik:GridTemplateColumn>
                                                                   <telerik:GridTemplateColumn HeaderText="No. Of Locations">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblPrintLocationStyleNoOfLocations" runat="server" Text="" DataField="PrintLocationStyleNumOfLocations" ></asp:Label>
                                                                        </ItemTemplate>
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn HeaderText="Last Changed">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblPrintLocationStyleLastChanged" runat="server" Text="" DataField="PrintLocationStyleLastUpdated" ></asp:Label>
                                                                        </ItemTemplate>
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn HeaderText="Created">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblPrintLocationStyleCreated" runat="server" Text="" DataField="PrintLocationStyleDateCreated" ></asp:Label>
                                                                        </ItemTemplate>
                                                                    </telerik:GridTemplateColumn>
                                                                    <%--<telerik:GridBoundColumn
                                                                        DataField="PrintLocationStyleNumOfLocations" HeaderText="No.Of Locations"
                                                                        UniqueName="PrintLocationStyleNumOfLocations">
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridBoundColumn DataField="PrintLocationStyleLastUpdated"
                                                                        HeaderText="Last Changed" UniqueName="PrintLocationStyleLastUpdated">
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridBoundColumn DataField="PrintLocationStyleDateCreated"
                                                                        HeaderText="Created" UniqueName="PrintLocationStyleDateCreated">
                                                                    </telerik:GridBoundColumn>--%>
                                                                </Columns>
                                                            </MasterTableView>
                                                            <HeaderStyle HorizontalAlign="Center" />
                                                            <FilterMenu EnableTheming="True">
                                                                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                                            </FilterMenu>
                                                        </telerik:RadGrid>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="cssNormalText" align="center">
                                        <asp:Button ID="btnAddNewStyle" runat="server" Height="28px" Text="Add new" Width="66px"
                                            ForeColor="#6666FF" TabIndex="1" ToolTip="Add New PrintLocationStyle" CssClass="cssButton" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <!-- Cost Profile End -->
                </table>
            </td>
        </tr>
    </table>
    <!-- Content Area End -->
    <!-- Footer Area Begin -->
    <asp:Table ID="tblDilogFooter" runat="server" Width="100%">
        <asp:TableRow>
            <asp:TableCell>
            </asp:TableCell>
        </asp:TableRow>
    </asp:Table>
    <!-- Footer Area End -->
    <script language="javascript" type="text/javascript">
        var hdnAction = document.getElementById('<%=hdnAction.ClientID %>');
        var hdnPrintLocationStyleID = document.getElementById('<%=hdnPrintLocationStyleID.ClientID %>');
        function DeleteCostProfileDetails(CPID, CPName) {
            var answer = confirm('Are you sure to delete ' + CPName + '?')
            if (answer) {
                hdnAction.value = 'PrintLocationStyle_DELETE';
                hdnCostProfileID.value = CPID;
                document.forms['aspnetForm'].submit();
            }
        }
    </script>
</asp:Content>
Posted
Updated 18-Feb-11 1:36am
v6
Comments
m@dhu 18-Feb-11 7:01am    
Link is redirecting back here. Update it.
pkarthionline 18-Feb-11 7:31am    
i have grid bind problem
Abdul Quader Mamun 18-Feb-11 8:15am    
Big question.

1 solution

RadGrid is a Telerik object. Since your issues may be directly related to their class, I would recommend posting this question in their forum which can be found here:

http://www.telerik.com/community/forums.aspx
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900