0
下面的代碼拋出誤差 沒有重載「FmtClr」匹配委託「System.EventHandler」沒有重載「FmtClr」匹配委託「System.EventHandler」
即使這樣,處理程序的參數傳遞
isit問題與我添加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>
您好。您的'FmtClr'方法不必在 OnItemDataBound ..上調用。 –
2013-04-24 11:32:35