Click here to Skip to main content
15,921,463 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using GridView control for uploading files I am uploading using RowCommand Event, My scenario is like this
1: User login and comes to the page and upload file
2: User login, enter some data and save it,post back will occur and data will be shown in Grid.

The Upload functionality is working fine in scenario 1, however its not working after scenario 2
This is my Code


XML
<asp:GridView ID="GVUsers" runat="server" OnRowDataBound="GVUsers_RowDataBound" OnRowCommand="GVUsers_RowCommand"
    OnRowDeleting="GVUsers_RowDeleting" AutoGenerateColumns="false" CssClass="table">
    <Columns>
            <asp:TemplateField HeaderText="Files" ItemStyle-HorizontalAlign="Left">
                <ItemTemplate>
                    <asp:FileUpload ID="filedoc" runat="server" Width="98%" CssClass="filedoc" />
                    <asp:Button ID="btnuploadfiles" runat="server" CommandName="fileupd" Text="Upload"
                                                            CssClas="uploadbtn" />
                </ItemTemplate>
                 </asp:TemplateField>


    </Columns>
</asp:GridView>

protected void GVUsers_RowCommand(Object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "fileupd")
    {
            //Upload File
    }
}



and this is how I am databinding
C#
if(!Page.IsPostBack)
{
//Bind GridView
}


I also tried binding grid after the above condition,ie Binding Grid always,but no Luck

I tried assinging event handler from code behind,but same issue.
How can I make RowCommand Working after post back?
Posted
Comments
Laiju k 16-May-14 5:53am    
Have You debugged with breakpoints.Is the GVUsers_RowCommand event firing
Syed Salman Raza Zaidi 16-May-14 8:27am    
yes I guess the problem is after saving, as I am again assigning Datasource and databinding grid on save

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900