>
按常规声明代码
Page language=“vb”autoeventwireup=“false”masterpageFile=“~/site.master”codeBehind=“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>
<%@ 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>
看过之后,我有两个可能的建议给你-
1)检查绑定网格视图的位置-
应该在里面-!ISPostback
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
grid.DataBind();
}
}
对于那些有这个问题的人,我会帮你省去一些头痛。 总之:Pjax链接选择器必须指向一个 我遇到的问题是使用Pjax更新Gridview小部件之外的内容。我使用Html::button添加了一个自定义按钮,但pjax由于未知原因失败。 在gridview小部件上测试pjax时,使用'class'=本机按钮 收到此错误:未捕获$。fn。pjax或$。pjax。单击需要一个锚元素。 文件位置:app/vi
我正在构建一个反应轨道应用程序。我在页面上有一个按钮,用户可以指示他们是否要加入会议。单击“join”按钮应在当前用户和事件之间创建一个rsvp关系,该按钮将切换到“Leave”,如果用户随后单击“Leave(离开)”按钮,该关系将从rails后端删除。在搞乱我的react组件后,我的“Join”按钮没有触发“onSubmit”功能,“Leave”按钮似乎返回了一个错误消息“submission
问题内容: 添加按钮具有事件OnClick =“ btn_Add_Click” 该事件未触发,当我单击添加按钮时,没有任何反应。而且,在我添加更新面板之前,“更新按钮”工作正常,现在只有“取消”按钮关闭了弹出窗口,而其他按钮在弹出窗口内无法正常工作如何触发事件。 问题答案: 将UpdatePanel的属性更改为。这将导致由UpdatePanel的子元素触发的任何回发更新其内容。 编辑 :刚刚意识到
问题内容: 似乎是一个简单的问题,但解决其他问题的方法似乎对我没有用。 试图通过单击按钮来触发AJAX请求,但似乎并未触发。 HTML示例 javascript 问题答案: 您拥有的代码在拨弄中工作得很好。初始页面加载后,按钮是否通过AJAX动态呈现? 用 代替
我是一个新手,我正在尝试创建一个应用程序来在我的投资组合中使用。本质上,该程序是一个可以访问不同菜单的菜单(json文件:texas_pick.js,Breakth.js…),该程序旨在以按钮的形式显示菜单选项,按钮的详细信息从各自的json文件中检索。我面临的问题是,单击菜单选项时,会检索最后一个菜单项的数据。我将后端编程为只将商品名称和价格推送到数据库,而前端则检索这些数据并将其显示在表上。检
我在一个页面上有两个GridView,每个GridView都在代码隐藏中被修改为使用RowDataBound进行分组,在RowDataBound中,我为每个分组添加了一个文本框和按钮。该按钮将添加一个单击事件。此外,每个GridView都位于UpdatePanel中。 为了解决RowDataBound项和动态控件的回发问题,我添加了一个简单的响应。重定向到同一页。这段代码可以工作,但按钮会在Gri