Reputation: 45
I have a gridview with a linkbutton. I set up a lightbox for the linkbutton using jquery and css.
Linkbutton source code
<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>
I have to set the content of lightbox in rowcommand event.I use the following code in rowdatabound.
cname.CssClass = "popup-with-zoom-anim";
cname.Attributes.Add("href", "#smalldialog");
The script is,
<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>
But rowcommand not firing so lightbox displaying no data.Any help appreciated.
Upvotes: 1
Views: 2129
Reputation: 10565
Well there can be more than one reason for this behaviour. Perform the following checks:
Do NOT bind your GridView
on postbacks in Page_Load
event. Means to say if you are binding your GridView from Code behind, bind it only for first time::
if ((!Page.IsPostback)) { GridView1.DataBind(); }
Do NOT disable ViewState
for GridView
Last option and Least expected is that OnRowCommand
attribute may be missing/not
defined in the gridView markup. Make sure you have defined an event handler for your Row Command event, something as :
<asp:GridView OnRowCommand="Event_Handler_Here" .. />
Upvotes: 1