[英]Error while passing parameter to RadGrid_NeedDataSource() Event
I am trying to pass DataTable to RadGrid NeedDataSource event function and assign that DataTable to RadGrid but facing below error:我正在尝试将 DataTable 传递给 RadGrid NeedDataSource 事件 function 并将该 DataTable 分配给 RadGrid 但面临以下错误:
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: CS0123: No overload for 'RadGrid2_NeedDataSource' matches delegate 'GridNeedDataSourceEventHandler'
编译器错误消息:CS0123:“RadGrid2_NeedDataSource”没有重载与委托“GridNeedDataSourceEventHandler”匹配
Source Error:
源错误:
Line 241: <telerik:RadAjaxLoadingPanel runat="server" ID="gridLoadingPanel" Skin="Vista"></telerik:RadAjaxLoadingPanel> Line 242: Line 243: <telerik:RadGrid RenderMode="Lightweight" ID="RadGrid2" runat="server" GridLines="None" Visible="false" AllowSorting="True" AllowPaging="True" PageSize="10" Width="100%" OnNeedDataSource="RadGrid2_NeedDataSource" OnItemDataBound="RadGrid2_ItemDataBound" Skin="Metro" HeaderStyle-Font-Size="8px" PagerStyle-Font-Size="12px" CellSpacing="0"> Line 244: Line 245:
第 241 行:<telerik:RadAjaxLoadingPanel runat="server" ID="gridLoadingPanel" Skin="Vista"></telerik:RadAjaxLoadingPanel> 第 242 行:第 243 行:<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid2" runat ="server" GridLines="None" Visible="false" AllowSorting="True" AllowPaging="True" PageSize="10" Width="100%" OnNeedDataSource="RadGrid2_NeedDataSource" OnItemDataBound="RadGrid2_ItemDataBound" Skin="Metro" HeaderStyle-Font-Size="8px" PagerStyle-Font-Size="12px" CellSpacing="0"> 第 244 行: 第 245 行:
My C# code:我的 C# 代码:
DataTable dt=new DataTable();
Radgrid2.NeedDataSource += new GridNeedDataSourceEventHandler((sender, e) => RadGrid2_NeedDataSource(sender, e, dt));
protected void RadGrid2_NeedDataSource(object sender, GridNeedDataSourceEventArgs e, DataTable t)
{
RadGrid2.DataSource=t;
}
ASP.NET Code: ASP.NET 代码:
<telerik:RadGrid RenderMode="Lightweight" ID="RadGrid2" runat="server" GridLines="None" Visible="false" AllowSorting="True" AllowPaging="True" PageSize="10" Width="100%" OnNeedDataSource="RadGrid2_NeedDataSource" OnItemDataBound="RadGrid2_ItemDataBound" Skin="Metro" HeaderStyle-Font-Size="8px" PagerStyle-Font-Size="12px" CellSpacing="0">
<ClientSettings ReorderColumnsOnClient="true" AllowColumnsReorder="true" ColumnsReorderMethod="Reorder">
<Virtualization EnableVirtualization="true" InitiallyCachedItemsCount="2000" LoadingPanelID="RadAjaxLoadingPanel1" ItemsPerView="100"/>
<Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="true" FrozenColumnsCount="2"></Scrolling>
<Resizing AllowResizeToFit="false" AllowColumnResize="true" />
</ClientSettings>
<PagerStyle Mode="NumericPages" Height="1em"></PagerStyle>
<GroupingSettings CaseSensitive="false" />
</telerik:RadGrid>
What can be done for this?为此可以做些什么? any suggestion
任何建议
Start with reading the vendor documentation on this event.首先阅读有关此事件的供应商文档。 The handier you are trying to attach has the wrong signature, as the error message says.
如错误消息所述,您尝试附加的便利工具的签名错误。
Copy the proper one from the docs, remove the dynamic handier addition (you have it in the markup), get the data table inside the handler to give to the grid.从文档中复制正确的一个,删除动态的handier 添加(你在标记中有它),获取处理程序中的数据表以提供给网格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.