Telerik RadGrid ->如何对页脚中的 (nvarchar) 列求和?
我的 radgrid(telerik) 如下所示:
<telerik:RadGrid ID="grdUsers" runat="server" GridLines="None" Skin="Vista" DataSourceID="sdsUsers"
AllowPaging="True" AutoGenerateColumns="False" OnItemCommand="grdUsers_ItemCommand"
Width="900px" AllowSorting="True" PageSize="20">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="sdsUsers">
<DetailTables>
<telerik:GridTableView runat="server" DataKeyNames="ID,User_ID" DataSourceID="sdsDownload"
ShowFooter="True">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="User_ID" MasterKeyField="ID" />
</ParentTableRelation>
<CommandItemSettings ExportToPdfText="Export to Pdf" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column"
HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="User_ID" DataType="System.Int32" FilterControlAltText="Filter User_ID column"
HeaderText="User_ID" SortExpression="User_ID" UniqueName="User_ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FileSize" FilterControlAltText="Filter FileSize column"
HeaderText="FileSize" SortExpression="FileSize" UniqueName="FileSize" Aggregate="Sum">
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</telerik:GridTableView>
</DetailTables>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="ID" FilterControlAltText="Filter ID column" HeaderText="ID"
SortExpression="ID" UniqueName="ID">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FirstName" FilterControlAltText="Filter FirstName column"
HeaderText="FirstName" SortExpression="FirstName" UniqueName="FirstName">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
</telerik:RadGrid>
这是一个层次结构网格,有两个表(一个主表和一个详细表)。
我在详细信息表中有一个名为 (FileSize) 的列!
我的数据库中的这一列是 nvarchar(50),我想在详细信息表的页脚中显示文件大小的总和。
但是在此详细信息表中启用页脚并将 FileSize 列的聚合设置为 Sum 后,我收到一条错误,告诉您不能获得对象值的总和!
有没有办法对 FileSize 列进行求和?
my radgrid(telerik) is like below :
<telerik:RadGrid ID="grdUsers" runat="server" GridLines="None" Skin="Vista" DataSourceID="sdsUsers"
AllowPaging="True" AutoGenerateColumns="False" OnItemCommand="grdUsers_ItemCommand"
Width="900px" AllowSorting="True" PageSize="20">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="sdsUsers">
<DetailTables>
<telerik:GridTableView runat="server" DataKeyNames="ID,User_ID" DataSourceID="sdsDownload"
ShowFooter="True">
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="User_ID" MasterKeyField="ID" />
</ParentTableRelation>
<CommandItemSettings ExportToPdfText="Export to Pdf" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px" />
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="ID" DataType="System.Int32" FilterControlAltText="Filter ID column"
HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="User_ID" DataType="System.Int32" FilterControlAltText="Filter User_ID column"
HeaderText="User_ID" SortExpression="User_ID" UniqueName="User_ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FileSize" FilterControlAltText="Filter FileSize column"
HeaderText="FileSize" SortExpression="FileSize" UniqueName="FileSize" Aggregate="Sum">
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</telerik:GridTableView>
</DetailTables>
<CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="ID" FilterControlAltText="Filter ID column" HeaderText="ID"
SortExpression="ID" UniqueName="ID">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FirstName" FilterControlAltText="Filter FirstName column"
HeaderText="FirstName" SortExpression="FirstName" UniqueName="FirstName">
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</telerik:GridBoundColumn>
</Columns>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column">
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites="False">
</FilterMenu>
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
</HeaderContextMenu>
</telerik:RadGrid>
this is a Hierarchy grid with two tables (one master and one detail).
i have a column in detail table named (FileSize)!
this column in my database is nvarchar(50), i want to have sum of file sizes in the footer of detail table.
but after enabling Footer in this detail table and set aggregate of FileSize Column to Sum, i got an error that tells you can not have sum of object values!
is there a way for make sum of FileSize Column?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
aspx:
c#:
aspx :
c# :