本文介绍了RadGrid无法通过网格bind()帮助我.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对网格绑定有错误.


Gridexception未通过用户代码处理
-------------------------------------------------

这是从数据源提取DataKeyValues的问题.请确保正确指定了DataKeyNames,并且指定的所有字段都在DataSource中存在.

绑定网格时,我删除了3个字段,绑定成功,但是提醒绑定意味着我出错了.

拜托,有人可以帮忙吗?



谢谢,
卡尔提凯扬




我的代码:
==========

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:
==========

<%@ 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>

推荐答案


这篇关于RadGrid无法通过网格bind()帮助我.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 11:22