网格视图行命令事件不起作用 [英] Grid View Row Command Event Not Working

查看:86
本文介绍了网格视图行命令事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GridView控件上传我使用RowCommand事件上传的文件,我的场景是这样的

1:用户登录并进入页面并上传文件

2:用户登录,输入一些数据并保存,回发将发生,数据将显示在网格中。



上传功能在方案1中正常工作,但它在方案2之后无法工作

这是我的代码





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


<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

if(!Page.IsPostBack)
{
//Bind GridView
}





我在上述条件后也试过绑定网格,即Binding网格总是,但没有运气



我尝试从代码背后协助事件处理程序,但同样的问题。

如何使RowCommand工作后回复?



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?

推荐答案

这篇关于网格视图行命令事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆