将参数传递给radgrid_needdatasource()事件时出错

发布于 2025-02-12 04:26:46 字数 2252 浏览 2 评论 0原文

我正在尝试将DataTable通过到Radgrid oilddatasource事件功能,并将该数据分配给RadGrid,但面对以下错误:

描述:资源汇编期间发生了错误 需要服务此请求。请查看以下特定 错误详细信息并适当修改源代码。

编译器错误消息:CS0123:没有超载 'radgrid2_needdatasource'匹配委托 'gridneeddatasourceeventhandler'

源错误:

行241:< telerik:radajaxloadingpanel runat =“ server” id =“ gridloadingpanel” skin =“ vista”></telerik:radajaxloadingpanel>线 242:第243行:< telerik:radgrid rendermode =“轻量级” 可见=“ false”允许=“ true”允许=“ 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行:

我的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代码:

<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>

为此可以做什么?任何建议

I am trying to pass DataTable to RadGrid NeedDataSource event function and assign that DataTable to RadGrid but facing below 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: CS0123: No overload for
'RadGrid2_NeedDataSource' matches delegate
'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:

My C# code:

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:

<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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抱猫软卧 2025-02-19 04:26:46

首先阅读此事件的供应商文档。正如错误消息所说,您试图附加的方便性的签名错误。

从文档中复制适当的功能,删除动态的便携式添加(在标记中添加),将数据表在处理程序内部输入网格。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文