简体   繁体   English

如何在RadTabStrip的标题中显示Radgrid的总行数

[英]How to Show Total Row Count of a Radgrid in the Header of a RadTabStrip

I have an ASP.NET project in C# that uses a sqlDataSource. 我在C#中有一个使用sqlDataSource的ASP.NET项目。 The project consists of a Telerik Radgrid, which sits on a RadTabStrip. 该项目由位于RadTabStrip上的Telerik Radgrid组成。 I would like to know how I can possibly add the total row count of that grid into the Header Tab like seen in following image 我想知道如何将网格的总行数添加到“标题”选项卡中,如下图所示

在此处输入图片说明

I haven't worked with the RadTabStrip much so I don't know how to set that problematically; 我与RadTabStrip的合作不是很多,所以我不知道如何设置问题。 however, I've done something similar by displaying the item count elsewhere on the page. 但是,我通过在页面其他位置显示项目计数来完成类似的操作。 Perhaps this will help you achieve what you desire. 也许这可以帮助您实现自己的愿望。

First, you'll should add a HiddenField into the page which will stored the number of items in the RadGrid. 首先,您应该将HiddenField添加到页面中,该页面将在RadGrid中存储项目数。

<asp:HiddenField ID="HiddenField1" runat="server" />

Next, in the code behind, stick the number of items int he RadGrid into the HiddenField. 接下来,在后面的代码中,将RadGrid中的项目数粘贴到HiddenField中。

protected void Page_LoadComplete(object sender, EventArgs e)
{
    HiddenField1.Value = RadGrid.Items.Count.ToString();
{

Finally, on PageLoad, grab the value of the HiddenField and append it to the tab text. 最后,在PageLoad上,获取HiddenField的值并将其附加到选项卡文本中。

$(document).ready(function () {
   var totalItems = $("#HiddenField1").val();
   $("#OpenTradesTab").Text("Open Trades (" + totalItems  + ")")
});

Hope this helps. 希望这可以帮助。

You can get an approximate answer by doing: 您可以通过以下方式获得大致的答案:

dgGrid.PageCount * dgGrid.PageSize dgGrid.PageCount * dgGrid.PageSize

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM