LinkButton RowCommand event not triggering in GridView - Can anyone help?

I have a gridview that contains a link button. Using jQuery and CSS, I've set up a lightbox for the link button.

Here's the source code for the link button:

<asp:TemplateField HeaderText="Course" ItemStyle-CssClass="course" HeaderStyle-CssClass="course">
                <ItemTemplate>
                    <asp:LinkButton ID="Course_Name" runat="server"   Text='<%# Eval("Course_Name__c") %>' ForeColor="#666699" CommandName="course" CommandArgument='<%# ((GridViewRow) Container).RowIndex %>'  ></asp:LinkButton>
                </ItemTemplate>
                <HeaderStyle Font-Bold="True" />

                <HeaderStyle HorizontalAlign="Center"/>
                <ItemStyle CssClass="course"></ItemStyle>
            </asp:TemplateField>

In order to populate the content of the lightbox in the rowcommand event, I'm using the following code in rowdatabound:

  cname.CssClass = "popup-with-zoom-anim";
        cname.Attributes.Add("href", "#smalldialog");

The script used for this purpose is as follows:

    <script type="text/javascript">
    $(document).ready(function () {
        $('.popup-with-zoom-anim').magnificPopup({
            type: 'inline',

            fixedContentPos: false,
            fixedBgPos: true,

            overflowY: 'auto',

            closeBtnInside: true,
            preloader: false,

            midClick: true,
            removalDelay: 300,
            mainClass: 'my-mfp-zoom-in'
        });

        $('.popup-with-move-anim').magnificPopup({
            type: 'inline',

            fixedContentPos: false,
            fixedBgPos: true,

            overflowY: 'auto',

            closeBtnInside: true,
            preloader: false,

            midClick: true,
            removalDelay: 300,
            mainClass: 'my-mfp-slide-bottom'
        });
    });
</script>

However, the rowcommand is not firing, causing the lightbox to display no data. Any help on resolving this issue would be greatly appreciated.

Answer №1

There could be several reasons for this particular behavior. Here are some steps to troubleshoot:

  1. Avoid binding your GridView on postbacks within the Page_Load event. Only bind it for the first time like so:

    if ((!Page.IsPostback)) { GridView1.DataBind(); }

  2. Make sure that you do not disable ViewState for the GridView

  3. Another possibility is that the OnRowCommand attribute might be missing or not defined in the markup of the gridView. Make sure you have an event handler defined for your Row Command event, such as:

    <asp:GridView OnRowCommand="Event_Handler_Here" .. />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Is there a way to restrict access to a website on Chrome using HTML code?

I'm trying to block a website on Chrome using HTML. When I try, a pop-up appears. If I click OK, the site is blocked, but if I click cancel, it continues to load. How can I resolve this issue? See below for the code and screenshot: <html& ...

Display the text when the button is clicked

This section is designed to present a riddle. When you click the button, it reveals the answer. <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Puzzles</title> <link href="/css/favicon.ico" rel= ...

Failure of PrimeNG Autocomplete dropdown to adjust position

My experience with the PrimeNG Autocomplete plugin resulted in some conflicts. When using this style, the autocomplete drop-downs are positioned downward. Image description goes here https://i.sstatic.net/VZmAk.png If anyone knows how to resolve this is ...

Tips for arranging Angular Material cards in columns instead of rows

I am currently developing a web application using Angular, and I've encountered an issue while trying to display cards in a vertical layout rather than horizontally. My goal is to have the cards fill up the first column (5-6 cards) before moving on to ...

Guide to invoking a bootstrap modal dynamically within a loop with the help of jQuery

I'm currently facing an issue with my code that involves inserting data into a database. The code is set up to check if the data already exists, and if it does, prompt the user with a Bootstrap modal to confirm whether they want to continue adding the ...

What is the best way to retrieve the text from a linked button within my rad grid using jQuery?

I am facing an issue with a grid that contains link-buttons in the code column. The user can check multiple checkboxes, and when they click on the top button of my page, all selected codes will be displayed in a text box on another page using a jQuery func ...

Implementing OR logic for event handlers with jQuery

I have a dropdown list where I want to make an ajax call on both onchange and onload events. $('#id').change(function() { // ajax call }); Instead of just calling the ajax on change, I also need it to be triggered on page load. My current log ...

Elegant Bootstrap 4 Carousel featuring a glimpse of the upcoming slide alongside the primary carousel item

I am in search of a straightforward Bootstrap 4 carousel that showcases a glimpse of the next slide on the right. Despite exploring similar questions, I have not found a suitable solution. The links to those questions are: 1)Bootstrap carousel reveal part ...

Adjust the width of list elements according to object properties within an array with jquery

Within my array, there are several objects stored. var country_data = [ {"country_id":1,"country":"Luxembourg","local_wage":"407","wage":"489","exchange":"0.98"}, {"country_id":2,"country":"Norway","local_wage":"3200","wage":"378","exchange":"9.57"}, {"co ...

How to trigger a submit action on a different page from an iframe using PHP

Is there a way to submit the iframe page using the modal's submit button in Page1.php to trigger the submit button of Page2.php? I need help executing this efficiently. The purpose of having the submit button in a modal is to perform multiple functio ...

Enhance the appearance of the CKEditor by applying CSS styling to both the Preview

Can I apply CSS to customize the appearance of both the Editor text and the Preview? The CMS uses separate CSS files for the backend compared to the frontend of the website, and I would like the editor to mimic how the content will appear on the site. Fo ...

The body element is inheriting the background-color

I am attempting to create a layout with two stacked elements and a footer. .background .container-fluid .footer You can view my code on this fiddle: http://jsfiddle.net/z9Unk/309/ My expectation is for the background to be displayed in green with the ...

jQuery is experiencing issues when attempting to add multiple rows to a table

I am currently working on building a function that takes an input and uses it to construct a grid. My main focus at the moment is getting the grid functionality up and running, but I've run into a strange issue. Despite searching for hours, all the so ...

Handling Input values and Select options jointly in an event listener

I am faced with the challenge of validating and capturing multiple input values along with a select box option based on the keypress event. My goal is to gather all data from the input fields and the select box, and then send this information using the key ...

What is the method for moving one div above or below another div using the scroll bar?

Here's the scenario I'm facing: I have rows with buttons that, when clicked, reveal a set of options. The challenge is that depending on where the row is located on the page, the settings need to open either above or below the button. When the b ...

"Exploring the screen size options in Chrome version 38 using the

After the recent update, Chrome has introduced several new features for web developers. However, I've noticed that when you drag the screen with the developer tools open, it used to display the exact screen width size in the top right corner. Now, it ...

Mobile phone carousel glitch

I am encountering an issue with the Bootstrap v4.0 Carousel that I can't seem to resolve. Despite searching online for similar problems, I have not been able to find a solution, which is quite perplexing. Whenever I load a page on an iPhone, the caro ...

Expand a div without causing any displacement to surrounding elements

If you have 4 colored divs (red, yellow, green, blue), with 2 per row, and need to expand the second (yellow) without creating a gap under the red, check out this solution. The blue will be positioned underneath the expanded yellow. For a live example, vi ...

How can I achieve this particular design using flexbox?

Check out the image here: . I'm struggling to understand the examples and live flex configurators. Are they only showing simple examples, or am I just not grasping it? Is it possible for me to use media queries to hide a4 when the screen is less than ...

Tips for increasing the size of Material-ui Rating icons

I am currently utilizing npm to develop a widget. I aim to utilize the material-ui Rating component and have successfully integrated it. However, when I embed the widget on a webpage, the html font-size is set at 62.5%, causing the component to appear too ...