这是尝试渲染网格项(单元格)失败的脚本。想法是处理输入值并将其返回到单元格 - 渲染。
ASP
<asp:GridView ID="GridView_stations" runat="server" AutoGenerateColumns="False"
DataSourceID="mailreport" AllowSorting="True" Width="100%" AllowPaging="True">
<Columns>
<asp:BoundField DataField="id" HeaderText="ID" SortExpression="id" >
<HeaderStyle HorizontalAlign="Center" Width="70px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="name" ItemStyle-CssClass="padding-left" HeaderText="Name" SortExpression="name" >
<HeaderStyle CssClass="padding-left" HorizontalAlign="Left" />
<ItemStyle CssClass="padding-left"></ItemStyle>
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat="server" Text='<%#renderthis(Eval("id"))%>' CommandArgument='<%#Eval("id")%>' OnClick="DoRedirect" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="description" ItemStyle-CssClass="padding-left" HeaderText="Description"
SortExpression="description" >
<HeaderStyle CssClass="padding-left" HorizontalAlign="Left" />
<ItemStyle CssClass="padding-left"></ItemStyle>
</asp:BoundField>
<asp:BoundField DataField="name" HeaderText="Last report"
SortExpression="name" >
<HeaderStyle HorizontalAlign="Center" Width="120px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="name" HeaderText="Status" SortExpression="name" >
<HeaderStyle HorizontalAlign="Center" Width="100px" />
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
</asp:GridView>
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MailReport
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected string renderthis(string sender)
{
string str = sender.ToString()+"-str";
return str;
}
protected void DoRedirect(object sender, EventArgs e)
{
Button theButton = sender as Button;
Response.Redirect("Newpage.aspx?ID=" + theButton.CommandArgument);
}
}
}
错误:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1502: The best overloaded method match for 'MailReport.WebForm1.renderthis(string)' has some invalid arguments
Source Error:
Line 25: <asp:Button runat="server" **
Text='<%#renderthis(Eval("id"))%>'** CommandArgument='<%#Eval("id")%>' OnClick="DoRedirect" />
请你能帮我理解这个错误以及如何继续。