Search code examples
telerikradgrid

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. The project consists of a Telerik Radgrid, which sits on a RadTabStrip. 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

enter image description here


Solution

  • I haven't worked with the RadTabStrip much so I don't know how to set that problematically; 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.

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

    Next, in the code behind, stick the number of items int he RadGrid into the 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.

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

    Hope this helps.