Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6351147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:56:45+00:00 2026-05-24T21:56:45+00:00

I have created a RadGrid control dynamically on Page_PreInit event and added it to

  • 0

I have created a RadGrid control dynamically on Page_PreInit event and added it to a place holder on the page. my RadGridBuilder class has a Build() method.

My RadGrid has a custom button which is added at the time of ItemCreated event which is called during building the RadGrid (Page_PreInit):

protected virtual void RdGridItemCreated(object sender, GridItemEventArgs e)
    {          
        switch (e.Item.ItemType)
        {            
            // other codes
            case GridItemType.CommandItem:
                {
                    var gridCommandItem = e.Item as GridCommandItem;

                    AddPdfButton(gridCommandItem);

                    break;
                }
        }
    }


private void AddPdfButton(GridCommandItem gridCommandItem)
    {
        var pdfButton = CreateExportToPdfButton();

        try
            {
                PageUtil.RegisterPostBackControl(pdfButton);

                // this is the cell which contains the export buttons.
                ((Table) gridCommandItem.Cells[0].Controls[0]).Rows[0].Cells[1].Controls.Add(pdfButton);

            }
            catch
            {
                // LOG the error silently
            }
        }
    }
 private Button CreateExportToPdfButton()
    {
        var result = new Button();
        result.ID = "btnExportToPdf";
        result.Click += ExportToPdfButtonClick;
        result.CssClass = "rgExpPDF";
        result.CommandName = "ExportToPdfCustomCommand";
        result.Attributes["title"] = "Export to Pdf";
        return result;
    }
private void ExportToPdfButtonClick(object sender, EventArgs e)
   {
        // custom code
   }

The Pdf icon appears as expected on the RadGrid. When it is clicked, the post back happens (and the RadGrid is regenerated obviously on Page_PreInit again), however, the ExportToPdfButtonClick method is never called.

Why it is not called? how to fix it? it may be related to viewstate and control state?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T21:56:46+00:00Added an answer on May 24, 2026 at 9:56 pm

    RadGrid seems to be different apparently and didn’t figure out why the event wasn’t raised but found a solution.

    I created a new class implementing ITemplate interface and assigning it to the CommandItemTemplate property of my RadGrid.MasterTableView object.

    Then adding my custom controls in the Instantiate() method of my new class and finally the click event is raised; basically rebuilding my Command Row:

    http://www.telerik.com/help/aspnet-ajax/grid-commanditemtemplate.html

    Not sure at what point these controls are added to the RadGrid but must be before the RadGrid_ItemCreated and RadGrid_Load events and after RadGrid_Init event. anyway, it’s resolved now.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a RadGrid that has it's rows and columns being created programatically, and
I have created a UserControl that has a ListView in it. The ListView is
I have created a C# class file by using a XSD-file as an input.
Have created a custom navigation menu in wordpress that has some pages and some
I have added the Shadowbox on my page and it works fine when I
I have created a PHP form, which, upon submission, goes to another PHP page.
I have created an XML file in my solution path. My solution has multiple
I have a RadGrid on a sitefinity page, I am using it to create
I have created a controller class in which I have created a outlet to
Have created a c++ implementation of the Hough transform for detecting lines in images.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.