根据下拉选择动态设置asp:TableRow位置

时间:2014-12-29 20:15:17

标签: c# html asp.net

<div id="div1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel3" runat="server">
        <ContentTemplate>
            <asp:Table ID="Table1" runat="server" border="0" CssClass="SupplierFormTable" HorizontalAlign="Center" Width="100%">
                <asp:TableHeaderRow>
                    <asp:TableHeaderCell HorizontalAlign="Left" ColumnSpan="8">       Approval Sequence        </asp:TableHeaderCell>
                </asp:TableHeaderRow>
                <asp:TableRow>
                    <asp:TableCell Width="22%">
                     1.
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Seq1" runat="server" Width="35%" AppendDataBoundItems="true">
                            <asp:ListItem Text="--select--" Value="-1"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="22%">
                    2.
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Seq2" runat="server" Width="35%" AppendDataBoundItems="true">
                            <asp:ListItem Text="--select--" Value="-1"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="22%">
                    3.
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Seq3" runat="server" Width="35%" AppendDataBoundItems="true">
                            <asp:ListItem Text="--select--" Value="-1"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="22%">
                    4.
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Seq4" runat="server" Width="35%" AppendDataBoundItems="true">
                            <asp:ListItem Text="--select--" Value="-1"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="22%">
                    5.
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Seq5" runat="server" Width="35%" AppendDataBoundItems="true">
                            <asp:ListItem Text="--select--" Value="-1"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="22%">
                    6.
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Seq6" runat="server" Width="35%" AppendDataBoundItems="true">
                            <asp:ListItem Text="--select--" Value="-1"></asp:ListItem>
                        </asp:DropDownList>
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

我在div标签中有这个表。

<div id="div_Approvals" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:Table ID="tbl_Approvals" runat="server" border="0" CssClass="SupplierFormTable" HorizontalAlign="Center" Width="100%">
                <asp:TableHeaderRow>
                    <asp:TableHeaderCell HorizontalAlign="Left" ColumnSpan="8">
                     Approval                                             
                    </asp:TableHeaderCell>
                </asp:TableHeaderRow>

                <asp:TableRow  >
                    <asp:TableCell Width="22%">
                        <asp:Label runat="server" ID="lbl_HiringManager" Text="Hiring Manager :"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_HiringManagerName" runat="server" Width="35%"></asp:DropDownList>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_HiringManagerSignature" runat="server"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_HiringManagerDate" runat="server" ReadOnly="true" Visible="false"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell></asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_HiringManagerComment" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btn_HiringManagerApprove" Text="Approve" runat="server" OnClick="btn_HiringManagerApprove_Click" />
                        <asp:Button ID="btn_HiringManagerReApprove" Text="Re-Approve" runat="server" OnClick="btn_HiringManagerReApprove_Click" Visible="false" />
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow >
                    <asp:TableCell>
                        <asp:Label runat="server" ID="lbl_ReportingGroupExecutive" Text="Reporting Group Executive :"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_ReportingGroupName" runat="server" Width="35%"></asp:DropDownList>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_ReportingGroupExecutiveSignature" runat="server"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_ReportingGroupExecutiveDate" runat="server" Visible="false"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell></asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_ReportingGroupExecutiveComment" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btn_ReportingGroup_Approve" Text="Approve" runat="server" OnClick="btn_ReportingGroup_Approve_Click" />
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>
                        <asp:Label runat="server" ID="lbl_ProgramOrProjectOwner" Text="Program/Project Owner (if applicable) :"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_PPO_Name" runat="server" Width="35%"></asp:DropDownList>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_ProgramOrProjectOwnerSignature" runat="server"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_ProgramOrProjectOwnerDate" runat="server" ReadOnly="true" Visible="false"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell></asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_ProgramOrProjectOwnerComment" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btn_PPO_Approve" Text="Approve" runat="server" OnClick="btn_PPO_Approve_Click" />
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>
                        <asp:Label runat="server" ID="lbl_Finance" Text="Finance"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_Finance" runat="server" Width="35%"></asp:DropDownList>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_FinanceSignature" runat="server"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_FinanceDate" runat="server" ReadOnly="true" Visible="false"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell></asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_FinanceComment" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btn_Finance_Approve" Text="Approve" runat="server" OnClick="btn_Finance_Approve_Click" />
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>
                        <asp:Label runat="server" ID="lbl_PresidentAndCOO" Text="President & COO (if applicable) :"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_PresidentAndCoo_Name" runat="server" Width="35%"></asp:DropDownList>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_PresidentAndCOOSignature" runat="server"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_PresidentAndCOODate" runat="server" ReadOnly="true" Visible="false"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell></asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_PresidentAndCOOComment" runat="server" TextMode="MultiLine"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btn_PresidentAndCoo_Approve" Text="Approve" runat="server" OnClick="btn_PresidentAndCoo_Approve_Click" />
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell>
                        <asp:Label runat="server" ID="lbl_HR" Text="Human Resources :"></asp:Label>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:DropDownList ID="drpdwnlst_HR_Name" runat="server" Width="35%"></asp:DropDownList>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_HRSignature" runat="server"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_HRDate" runat="server" ReadOnly="true" Visible="false"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell></asp:TableCell>
                    <asp:TableCell>
                        <asp:TextBox ID="txt_HRComment" runat="server" TextMode="MultiLine" Width="100%"></asp:TextBox>
                    </asp:TableCell>
                    <asp:TableCell>
                        <asp:Button ID="btn_HR_Approve" Text="Approve" runat="server" OnClick="btn_HR_Approve_Click" />
                    </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        </ContentTemplate>
    </asp:UpdatePanel>
</div>

要求是根据下拉选择,我想更改表 tbl_Approvals 的TableRow的位置。

如何实现此目标,因为我无法在<div>内使用<asp:Table>

1 个答案:

答案 0 :(得分:0)

如果是我,我会创建我想要的不同样式作为CSS类,然后当您的下拉列表的索引更改时,使用以下内容更改表(或有意义的行)的class属性:

 [object id].Attributes.Add("style", "someCssClass;");