Gridview Row_Command is not firing inside updatepanel

Last post 08-18-2009 11:06 AM by Setty. 3 replies.

Sort Posts:

  • Gridview Row_Command is not firing inside updatepanel

    08-17-2009, 4:53 PM
    • Member
      24 point Member
    • Setty
    • Member since 12-03-2007, 11:17 AM
    • Posts 137

     I want to download a file when the user clicks on filepath in grdiview without refreshing page.Here is the code am trying to do

    But am seeing that rowcommand is not firing at all..please let me know..

     

    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">

     

    <ContentTemplate>

     

     

    <asp:GridView ID="gvUploadProposals" runat="server" AutoGenerateColumns="false" EmptyDataText="No Data Found" onrowcreated="gvUploadProposals_RowCreated">

     

    <Columns>

     

    <asp:BoundField DataField="UploadFileTypeName" HeaderText="FileTypeName" />

     

    <asp:BoundField DataField="UploadFileName" HeaderText="FileName" />

     

    <asp:TemplateField HeaderText="FileIsFinal">

     

    <ItemTemplate>

     

    <asp:CheckBox ID="chkFileIsFinal" runat="server" Enabled="false" />

     

    </ItemTemplate>

     

    </asp:TemplateField>

     

    <asp:TemplateField HeaderText="Download Document">

     

    <ItemTemplate>

     

    <asp:LinkButton ID="lnkDownloadFile" runat="server" Text='<%#Eval("UploadFilePath")%>'

     

    CommandName="Download" CausesValidation="False"> <%#DownloadFile(Eval("UploadFilePath").ToString())%></asp:LinkButton>

     

    </ItemTemplate>

     

    </asp:TemplateField>

     

    </Columns>

     

    </asp:GridView>

     

    </ContentTemplate>

     

    <Triggers>

     

    <asp:AsyncPostBackTrigger ControlID="gvUploadProposals" EventName="RowCommand" />

     

    <asp:AsyncPostBackTrigger ControlID="ddlDocumentType" EventName="SelectedIndexChanged" />

     

    </Triggers>

     

     

    </asp:UpdatePanel>

    Thanks,

    Vishnu

  • Re: Gridview Row_Command is not firing inside updatepanel

    08-17-2009, 6:50 PM
    Answer

    Try handling the GridView's RowCommand event which should trigger when the LinkButton is clicked.

  • Re: Gridview Row_Command is not firing inside updatepanel

    08-17-2009, 11:05 PM

     Add an OnClientClick attribute to your LinkButton, and set it to window.open("").  This will trigger the window open prior to post back. then you can call the download file code here

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: Gridview Row_Command is not firing inside updatepanel

    08-18-2009, 11:06 AM
    Answer
    • Member
      24 point Member
    • Setty
    • Member since 12-03-2007, 11:17 AM
    • Posts 137

     Thanks and i got it solved with row_ondatabound event:

     

     

     

     

    protected void GridView1_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton button = (LinkButton)e.Row.FindControl("lnkTitle");
                string desc = DataBinder.Eval(e.Row.DataItem, "Description").ToString();
    
                button.Attributes.Add("onclick", string.Format("userSelected('{0}')", desc));
            }
        }

     

     

     

Page 1 of 1 (4 items)