显示/隐藏基于链接按钮的项目单击ASP Web窗体?

时间:2014-11-29 17:51:44

标签: c# asp.net gridview

我一直试图让这个代码起作用,但对于我的生活,我无法理解。我在GridView中有一个LinkBut​​ton,我点击它,填充另一个GridView和一个Repeater。我的问题在于第二个GridView下面的项目。我有两个LinkBut​​tons,一个Label和一个TextBox,我需要隐藏它,直到显示第二个gridview。到目前为止,我已经尝试设置“Visible = false”并在单击LinkBut​​ton时在后面的代码中切换为true,但没有显示,我尝试关闭验证和其他一些事情但是到目前为止没有运气,这是我试过的最后一件事:

网络表单代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ReceivingPage.aspx.cs" Inherits="Receiving_ReceivingPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<h1 class="well">Receiving</h1>
<asp:ObjectDataSource ID="ODSOpenPOList" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetOpenPO" TypeName="eToolsSystem.BLL.ReceiveController"></asp:ObjectDataSource>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ODSOpenPOList">
    <Columns>
        <asp:BoundField DataField="PurchaseOrderID" HeaderText="Order" SortExpression="PurchaseOrderID" />
        <asp:BoundField DataField="OrderDate" HeaderText="Order Date" SortExpression="OrderDate" />
        <asp:BoundField DataField="VendorName" HeaderText="Vendor" SortExpression="VendorName" />
        <asp:BoundField DataField="Phone" HeaderText="Contact Phone" SortExpression="Phone" />
        <asp:TemplateField>
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<%# "ReceivingPage.aspx?id="+Eval("PurchaseOrderID") %>' CausesValidation="True" OnClick="LinkButton1_Click">View Order</asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ODSPopulatePOItemList" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetPOItemByPurchaseOrderID" TypeName="eToolsSystem.BLL.ReceiveController">
    <SelectParameters>
        <asp:QueryStringParameter Name="purchaseOrderId" QueryStringField="id" Type="Int32" />
    </SelectParameters>
</asp:ObjectDataSource>

<asp:ObjectDataSource ID="ODSVendorByID" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetVendorByID" TypeName="eToolsSystem.BLL.ReceiveController">
    <SelectParameters>
        <asp:QueryStringParameter Name="purchaseOrderId" QueryStringField="id" Type="Int32" />
    </SelectParameters>
</asp:ObjectDataSource>
<br />
<asp:Repeater ID="VendorRepeater" runat="server" DataSourceID="ODSVendorByID">
    <ItemTemplate>
        PO #<%# Eval("PurchaseOrderID") %>Vendor: <%# Eval("VendorName") %>
        Contact Phone:<%# Eval("Phone") %>

    </ItemTemplate>
</asp:Repeater>

<asp:GridView ID="ReceiverPanel" runat="server" AutoGenerateColumns="False" DataSourceID="ODSPopulatePOItemList">
    <Columns>
        <asp:BoundField DataField="StockItemID" HeaderText="StockItemID" SortExpression="StockItemID" />
        <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
        <asp:BoundField DataField="QuantityOnOrder" HeaderText="QuantityOnOrder" SortExpression="QuantityOnOrder" />
        <asp:BoundField DataField="QuantityOutstanding" HeaderText="Outstanding" SortExpression="QuantityOutstanding" />
        <asp:TemplateField HeaderText="Receive" Visible="True">
            <ItemTemplate>
                <asp:TextBox runat="server" ID="Received" Text='<%# Eval("Received") %>'></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Return">
            <ItemTemplate>
                <asp:TextBox runat="server" ID="Returned" Text='<%# Eval("ReturnedQuantity") %>'></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Reason">
            <ItemTemplate>
                <asp:TextBox runat="server" ID="Reason" Text='<%# Eval("Reason") %>'></asp:TextBox>
                <asp:HiddenField ID="PurchaseOrderDetailID" runat="server" Value='<%# Bind("PurchaseOrderDetailID") %>' />
                <asp:HiddenField ID="PurchaseOrderID" runat="server" Value='<%# Bind("PurchaseOrderID") %>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

<asp:LinkButton ID="ReceiveButton" runat="server" OnClick="ReceiveButton_Click" Visible="false">Receive</asp:LinkButton>
<asp:LinkButton ID="ForceClose" runat="server" OnClick="ForceClose_Click" Visible="false">Force Close</asp:LinkButton>
<asp:Label ID="ReasonLabel" runat="server" Text="Reason:" Visible="false"></asp:Label>
<asp:TextBox ID="ForceCloseTextBox" runat="server" Visible="false"></asp:TextBox>

代码背后:

protected void LinkButton1_Click(object sender, EventArgs e)
{
    ForceClose.Visible = true;
    ReceiveButton.Visible = true;
    ReasonLabel.Visible = true;
    ForceCloseTextBox.Visible = true;
}

非常感谢任何解决方案!

0 个答案:

没有答案