0

the below code throwing error as No overload for 'FmtClr' matches delegate 'System.EventHandler'

Even though , the handler arguments are passed

isit the issue with the location i added the scipt .

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup=    
CodeBehind="Default.aspx.cs" Inherits="TestCertification._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script runat="server">     
   public void FmtClr(object sender, ListViewItemEventArgs e)
   {
       Label LineTotal = (Label)
       e.Item.FindControl("LineTotalLabel");
       if (LineTotal.Text.Length > 7)
       { LineTotal.ForeColor = System.Drawing.Color.Red; }
       else
       { LineTotal.ForeColor = System.Drawing.Color.Black; }
   }
   </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">   
<asp:SqlDataSource ID="SqlDataSource1" runat="server" OnDataBinding="FmtClr"
ConnectionString="<%$ ConnectionStrings:FXVanilla50ConnectionString %>" 
SelectCommand="SELECT top 2 [AddressId], [City], [State], [PostalCode], [Country] FROM       [Addresses]">    
</asp:SqlDataSource>

<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1">
   <ItemTemplate>
   <td>
   <asp:Label ID="LineTotalLabel" runat="server" Text='<%# Eval("City") %>' />
</td>
</ItemTemplate>
</asp:ListView> 
</asp:Content>
4

1 に答える 1

0

MSDNによると、SqlDataSource の DataBinding イベント ハンドラー シグネチャはobjectありますが、代わりにEventArgs指定しました。ListViewItemEventArgs署名を次のように変更します。

   public void FmtClr(object sender, EventArgs e)
   {
      //....
   }
于 2013-04-24T11:46:08.070 に答える