Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net GridView页脚中的按钮未触发_Asp.net_Vb.net_Button_Aspxgridview - Fatal编程技术网

Asp.net GridView页脚中的按钮未触发

Asp.net GridView页脚中的按钮未触发,asp.net,vb.net,button,aspxgridview,Asp.net,Vb.net,Button,Aspxgridview,单击GridViews页脚中的“我的按钮”时未触发。没有错误,没有代码被执行,它所做的只是一次刷新,页面上的所有内容都与单击按钮之前完全相同。调试甚至不执行 根据正常情况声明代码隐藏 Page Language=“vb”AutoEventWireup=“false”MasterPageFile=“~/Site.Master”codebeard=“RetailCompetition.aspx.vb” Inherits=“Company.Applications.Production.UI.Reta

单击GridViews页脚中的“我的按钮”时未触发。没有错误,没有代码被执行,它所做的只是一次刷新,页面上的所有内容都与单击按钮之前完全相同。调试甚至不执行

  • 根据正常情况声明代码隐藏

    Page Language=“vb”AutoEventWireup=“false”MasterPageFile=“~/Site.Master”codebeard=“RetailCompetition.aspx.vb” Inherits=“Company.Applications.Production.UI.RetailCompetition”

  • 事件

    Protected Sub dgvRetailCompetitions_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
    
        Try
            If e.CommandName = "Insert" AndAlso Page.IsValid Then
                Dim _refYear As Integer = (ddlYears.SelectedValue.ToString())
                Dim _rewardDescription As String = (CType(dgvRetailCompetitions.FooterRow.FindControl("txtRewardsDescription"), TextBox)).Text
                Dim _categoryACondition As Integer = (CType(dgvRetailCompetitions.FooterRow.FindControl("txtCatAConditions"), TextBox)).Text
                Dim _categoryBCondition As Integer = (CType(dgvRetailCompetitions.FooterRow.FindControl("txtCatBConditions"), TextBox)).Text
                Dim _categoryCCondition As Integer = (CType(dgvRetailCompetitions.FooterRow.FindControl("txtCatCConditions"), TextBox)).Text
    
                Company.Applications.Production.BusinessAccess.RetailCompetitionBusinessAccess.InsertNewRetailCompetitionRecord(_refYear,
                                                                                                                                       _rewardDescription,
                                                                                                                                       _categoryACondition,
                                                                                                                                       _categoryBCondition, _categoryCCondition)
            End If
        Catch ex As Exception
            InformationBox.ShowErrorMessage("Failed")
        End Try
    
    End Sub
    
  • 还有按钮

                            <asp:TemplateField HeaderText="Ref. Year" SortExpression="ReferenceYear" ItemStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("RefYear") %>' />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("RefYear") %>'></asp:Label>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:Button ID="btnInsertRecord" runat="server" CommandName="Insert" Text="Insert Record" ValidationGroup="Insert" CssClass="buttonBlue"/>
                                </FooterTemplate>
                            </asp:TemplateField>
    
    
    
  • 有人看到什么不对劲吗

    ASPX文件更新

    
    
    选择年份
    看了之后,我有两个可能的建议给你-

    1) 检查绑定网格视图的位置-

    它应该在里面!IsPostBack

    例如:

    2) 您是否在某个地方禁用了ViewState

    编辑-问题已解决

    在asp:GridView中,需要一个onrow命令来触发codebehind中的命令。将其添加到.aspx页面中的asp:gridview标记中


    onrowcommand=“dgvretail\u RowCommand”

    您好。添加了数据绑定,但它不起作用。做完全相同的事情。我不记得禁用了视图状态..我不这么认为。它实际上并没有做任何事情,就像一个没有代码的死按钮。我似乎找不到它是什么。@NikosV您可以更新.aspx页面或视图,以便我可以看到网格视图的onrow命令吗?(基本上,您正在进行的调用是为了触发dgvretailu RowCommand)@NikosV,正如我提到的.aspx页面内容,其中有网格视图。在文章中,您只在网格视图中包含了控件。我想
    <%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="RetailCompetition.aspx.vb"
        Inherits="Company.Applications.ProductionEngine.UI.RetailCompetition" %>
    
    <%@ Register Src="~/GenericControls/UC_GridViewSort.ascx" TagName="SortExtender"
        TagPrefix="uc" %>
    <%@ Register Src="~/GenericControls/UC_InformationMessageBox.ascx" TagName="InformationBox"
        TagPrefix="uc" %>
    <%@ Register Src="~/GenericControls/UC_GridFilter.ascx" TagName="GridFilter" TagPrefix="uc" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
        <asp:UpdatePanel ID="MainContentUpdatePanel" runat="server">
            <ContentTemplate>
                <h2>
                    <asp:Label ID="lblTitle" Text="Retail" runat="server" meta:resourcekey="lblTitle" />
                </h2>
                <br />
                <asp:Panel ID="panelRetailCompetitions" runat="server" Width="100%">
                    <div class="panels" style="padding-top: 0px; padding-bottom: 0px">
                        <h4 style="font-weight: bold">
                            <asp:Label ID="lblSectionTitle" runat="server" Text="Competition View" meta:resourceKey="lblSectionTitle" />
                        </h4>
                        <div class="panelContents" style="text-align: left;">
                            <asp:Table ID="tblRetailCompetitions" runat="server" Width="100%" CellSpacing="10">
                                <asp:TableRow>
                                    <asp:TableCell>
                                        Select Year
                                        <asp:DropDownList ID="ddlYears" runat="server" EnableViewState="true">
                                            <asp:ListItem Enabled="true" Value="-"></asp:ListItem>
                                            <asp:ListItem Text="2018" Value="2018"></asp:ListItem>
                                            <asp:ListItem Text="2019" Value="2019"></asp:ListItem>
                                            <asp:ListItem Text="2020" Value="2020"></asp:ListItem>
                                        </asp:DropDownList>
                                    </asp:TableCell>
                                </asp:TableRow>
                                <asp:TableRow>
                                    <asp:TableCell>
                                        <asp:Button ID="btnCopyToSelectedYear" runat="server" Text="Copy To Selected Year"
                                            Width="145px" CssClass="buttonBlue" />
                                    </asp:TableCell>
                                </asp:TableRow>
                                <asp:TableRow>
                                    <asp:TableCell>
                                        <uc:GridFilter ID="GridFilter" runat="server" EnableViewState="true" />
                                    </asp:TableCell>
                                </asp:TableRow>
                            </asp:Table>
                            <asp:GridView ID="dgvRetailCompetitions" runat="server" AutoGenerateColumns="False"
                                CellPadding="5" ForeColor="#333333" GridLines="Horizontal" BorderColor="#00728F"
                                BorderStyle="Solid" BorderWidth="2px" EmptyDataText="No Competitions Found!"
                                EmptyDataRowStyle-ForeColor="Red" EmptyDataRowStyle-HorizontalAlign="Center"
                                Width="100%" HorizontalAlign="Center" ShowHeaderWhenEmpty="True" AllowPaging="True"
                                PageSize="20" DataKeyNames="RewardDescription" AllowSorting="True" ShowFooter="True">
                                <AlternatingRowStyle BackColor="White" Width="70%" HorizontalAlign="Center" />
                                <Columns>
                                    <asp:CommandField ShowEditButton="true" EditText="Edit" UpdateText="Update" CancelText="Cancel" />
                                    <asp:CommandField ShowDeleteButton="true" DeleteText="Delete" />
                                    <asp:TemplateField HeaderText="Ref. Year" SortExpression="ReferenceYear" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("RefYear") %>' />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("RefYear") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <FooterTemplate>
                                            <asp:Button ID="btnInsertRecord" runat="server" CommandName="Insert" Text="Insert Record"
                                                ValidationGroup="Insert" CssClass="buttonBlue" />
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Reward Description" SortExpression="RewardDescription">
                                        <ItemTemplate>
                                            <asp:Label ID="lblRewardsDescription" runat="server" Text='<%# Eval("RewardDescription") %>' />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="txtRewardsDescription" runat="server" MaxLength="50" Text='<%# Eval("RewardDescription") %>'
                                                Width="200px" />
                                            <asp:CompareValidator ID="txtRewardsDescription_String" runat="server" ControlToValidate="txtRewardsDescription"
                                                Display="Dynamic" ErrorMessage="'Target' must be a string" ForeColor="Red" Operator="DataTypeCheck"
                                                SetFocusOnError="true" Type="String" />
                                        </EditItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" />
                                        <FooterTemplate>
                                            <asp:TextBox ID="txtRewardsDescription" runat="server"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvRewardsDescription" runat="server" ControlToValidate="txtRewardsDescription"
                                                ErrorMessage="Reward Description Required" Display="Dynamic" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Cat. A Conditions" SortExpression="CategoryA_Conditions">
                                        <ItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("CategoryA_Conditions") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:Label ID="Label3" runat="server" Text='<%# Eval("CategoryA_Conditions") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <FooterTemplate>
                                            <asp:TextBox ID="txtCatAConditions" runat="server"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvCatAConditions" runat="server" ControlToValidate="txtCatAConditions"
                                                ErrorMessage="Cat. A Conditions Required" Display="Dynamic" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Cat. B Conditions" SortExpression="CategoryB_Conditions">
                                        <ItemTemplate>
                                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("CategoryB_Conditions") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:Label ID="Label4" runat="server" Text='<%# Eval("CategoryB_Conditions") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <FooterTemplate>
                                            <asp:TextBox ID="txtCatBConditions" runat="server"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvCatBConditions" runat="server" ControlToValidate="txtCatBConditions"
                                                ErrorMessage="Cat. B Conditions Required" Display="Dynamic" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Cat. C Conditions" SortExpression="CategoryC_Conditions">
                                        <ItemTemplate>
                                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("CategoryC_Conditions") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:Label ID="Label5" runat="server" Text='<%# Eval("CategoryC_Conditions") %>'></asp:Label>
                                        </EditItemTemplate>
                                        <FooterTemplate>
                                            <asp:TextBox ID="txtCatCConditions" runat="server"></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvCatCConditions" runat="server" ControlToValidate="txtCatCConditions"
                                                ErrorMessage="Cat. C Conditions Required" Display="Dynamic" ValidationGroup="Insert"></asp:RequiredFieldValidator>
                                        </FooterTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <EditRowStyle BackColor="#4fb3cf" />
                                <EmptyDataRowStyle ForeColor="Red" HorizontalAlign="Center" />
                                <FooterStyle BackColor="#FBAD23" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />
                                <HeaderStyle BackColor="#FBAD23" Font-Bold="True" ForeColor="Black" />
                                <PagerStyle BackColor="#FBAD23" Font-Bold="true" ForeColor="Black" HorizontalAlign="Center" />
                                <RowStyle BackColor="#EFF3FB" HorizontalAlign="Center" />
                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                <SortedAscendingCellStyle BackColor="#F5F7FB" />
                                <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                                <SortedDescendingCellStyle BackColor="#E9EBEF" />
                                <SortedDescendingHeaderStyle BackColor="#4870BE" />
                            </asp:GridView>
                        </div>
                    </div>
                    <asp:ValidationSummary ID="validationSummary" runat="server" ValidationGroup="Insert"
                        ForeColor="Red" />
                </asp:Panel>
                <uc:SortExtender ID="dgvRetailCompetitions_SortExtender" runat="server" EnableViewState="true"
                    GridViewSortExpression="RewardDescription" GridViewSortDirection="Ascending" />
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <uc:InformationBox ID="InformationBox" runat="server" EnableViewState="true" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Content>
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            grid.DataBind();
        }
    }