0

I am creating ASP.net website I want to perform some action on two of gridview row command but that event is not firing on one of the web from. I have same thing in other page as well and it's working fine but I don't know Why it's not working for this page, please let me know if I am missing any thing or do I need to do something to make it work.

Page Load

protected void Page_Load(object sender, EventArgs e)
  {
if (!IsPostBack)
    {
        GridView1.DataSource = getData();
        GridView1.DataBind();
    }
}

Event

protected void GridView1_RowCommand1(object sender, GridViewCommandEventArgs e)
{
System.Diagnostics.Debug.WriteLine("command click:" + e.CommandName);
}

Designing

  <asp:GridView ID="GridView1" runat="server" CssClass="myGridClass"
      ShowHeaderWhenEmpty="True" EmptyDataText="No records Found"
     AutoGenerateColumns="False" Width="85%" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" CellPadding="2" ForeColor="Black" GridLines="Vertical" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCommand="GridView1_RowCommand1">
    <AlternatingRowStyle CssClass="alt" BackColor="White"></AlternatingRowStyle>
    <Columns>
                             <asp:TemplateField HeaderStyle-CssClass="gridheader">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton2" CommandName="DownloadImage" CommandArgument='<%# Eval("MIRImage")%>' runat="server">Download</asp:LinkButton>
                                    </ItemTemplate>
    </asp:TemplateField>
    </Columns>
</asp:GridView>
Zoe
  • 27,060
  • 21
  • 118
  • 148
Radhey.g
  • 37
  • 12
  • Check if you have disabled ViewState on Page.aspx, it should be at top of the file. – SehaxX Jun 13 '18 at 13:49
  • @SehaxX NO I have checked <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.master" CodeFile="MIR.aspx.cs" Inherits="MIR" %> – Radhey.g Jun 13 '18 at 13:51
  • Have you checked out some of these solutions: https://stackoverflow.com/questions/8494730/gridview-rowcommand-event-not-firing – SehaxX Jun 13 '18 at 13:53

1 Answers1

0

For now CausesValidation="false" into linkbutton did the job.

can any one explain me about that

Radhey.g
  • 37
  • 12
  • 1
    Do you have any validators associated with input control on the page? If yes then your link button click is validating those input controls – Mohsin Mehmood Jun 13 '18 at 14:04
  • 1
    https://stackoverflow.com/questions/14191235/i-must-add-causesvalidation-false-to-every-asp-button-to-work-why – SehaxX Jun 13 '18 at 14:05