ListView itemcommand event not working in IE8
<asp:ListView ID="lsvLanguage" runat="server"
ItemPlaceholderID="itmHolder"
OnItemCommand="lsvLanguage_ItemCommand">
<LayoutTemplate>
<asp:PlaceHolder ID="i开发者_StackOverflowtmHolder" runat="server">
</asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<div class="form_fields" style="width: 3%; padding-top: 0;">
<asp:LinkButton ID="lbtnCommand" runat="server"
CommandName="Language">
<asp:CheckBox ID="chkLanguage" CssClass="styled"
Checked='<%#Eval("IS_DEFAULT") %>'
runat="server" />
</asp:LinkButton>
</div>
<div class="form_fields" style="width: 10%;">
<asp:Label ID="lblDetailId" Visible="false" runat="server"
Text='<%#Eval("PARAM_DETAIL_ID") %>'>
</asp:Label>
<asp:Label ID="lblLanguage" runat="server"
Text='<%#Eval("PARAM_VALUE") %>'>
</asp:Label>
<asp:Label ID="lblLanguageKey" runat="server"
Text='<%#Eval("PARAM_KEY") %>' Visible="false">
</asp:Label>
</div>
</ItemTemplate>
</asp:ListView>
I have the above list control with itemcommand event. It is working fine in Firefox and Chrome but not in Internet Explorer 8.
Before getting into my answer, I'm wondering why you're embedding a CheckBox in a LinkButton? That could be a part of your problem.
As for the actual issue at hand, since the LinkButton is firing the command, you should be able to just add the OnCommand event handler directly to the LinkButton. If you need the row index, pass it in as your commadn argument, like this:
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Language" CommandArgument='<%#Container.ItemIndex%>' OnCommand="LinkButton1_Command" ...>
Then in your code behind:
protected void LinkButton1_Command(object sender, CommandEventArgs e)
{
GridViewRow row = GridView1.Rows[(int)e.CommandArgument];
if (row != null)
{
//do some logic on the row
}
//do some other logic outside of the row
}
精彩评论