0

我的网格视图:

<asp:GridView ID="MyGridView" runat="server" ShowFooter="true"
                                AutoGenerateColumns="False" Visible="True">
<Columns>
<asp:BoundField DataField="id" ItemStyle-HorizontalAlign="center"/>
<asp:BoundField DataField="fullName"  />
<asp:TemplateField HeaderText="situation>">
<ItemTemplate>
  <asp:DropDownList ID="dl_situation" runat="server">
   </asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField>
 <ItemTemplate>
         <asp:TextBox ID="tbNr" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>  
<asp:TemplateField HeaderText="Data">
<ItemTemplate>
 <asp:TextBox ID="tbDate" runat="server"></asp:TextBox>
 <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
      ErrorMessage="*" ControlToValidate="tbDate">
   </asp:RequiredFieldValidator>
 </ItemTemplate>
</asp:TemplateField>     
</Columns>
</asp:GridView>

当我试图填充 GridView 它给了我错误

Uncaught Sys.WebForms.PageRequestManagerServerErrorException:     
Sys.WebForms.PageRequestManagerServerErrorException: Exception has been 
thrown by the target of an invocation. ScriptResource.axd:847
Error$create ScriptResource.axd:847
PageRequestManager$_createPageRequestManagerServerError ScriptResource.axd:765
PageRequestManager$_parseDelta ScriptResource.axd:1654
PageRequestManager$_onFormSubmitCompleted ScriptResource.axd:1415
$type.createDelegate ScriptResource.axd:628
$type.getHandler ScriptResource.axd:4338
raise ScriptResource.axd:7248
WebRequest$completed ScriptResource.axd:7252
Sys.Net.XMLHttpExecutor._onReadyStateChange

在页面上的资源中,此错误位于此处

$type.create = function Error$create(message, errorInfo) {
    /// <summary locid="M:J#Error.create">Use this method to create a new error.   
   </summary>
    /// <param name="message" type="String" optional="true" mayBeNull="true">
     The error message.</param>
    /// <param name="errorInfo" optional="true" mayBeNull="true">
   A plain JavaScript object that contains extended information about the error.  
    The object should have a 'name' field that contains a string that identifies 
 the error   and any additional fields that are necessary to fully describe 
 the error.</param>
    /// <returns type="Error">An Error object.</returns>
    var e = Function._validateParams(arguments, [
        {name: "message", type: String, mayBeNull: true, optional: true},
        {name: "errorInfo", mayBeNull: true, optional: true}
    ]);
    if (e) throw e;

    var err = new Error(message);
**Uncaught Sys.WebForms.PageRequestManagerServerErrorException: 
Sys.WebForms.PageRequestManagerServerErrorException: 
 Exception has been thrown by the target of an invocation.**
    err.message = message;

    if (errorInfo) {
        for (var v in errorInfo) {
            err[v] = errorInfo[v];
        }
    }

    err.popStackFrame();
    return err;
}
4

1 回答 1

5

我遇到了同样的问题,并通过将ClientIDMode="AutoID"添加到 GridView ItemTemplate 中的验证器来解决它。

于 2013-12-17T05:22:19.473 回答