поместите часть вставки над таблицей в списках - PullRequest
0 голосов
/ 09 января 2012

На самом деле у меня есть список ниже на моей странице управления пользователем:

enter image description here

и я хочу заменить вставную часть над таблицей, как показано ниже:

enter image description here

и мой список просмотра выглядит следующим образом:

<asp:ListView ID="lv_Uc_Module" runat="server"
        onitemediting="lv_Uc_Module_ItemEditing" 
        onitemupdating="lv_Uc_Module_ItemUpdating" 
        onitemcanceling="lv_Uc_Module_ItemCanceling" 
        onitemdeleting="lv_Uc_Module_ItemDeleting"  
        OnItemDataBound="lv_Uc_Module_ItemDataBound"
        InsertItemPosition="LastItem"
        OnSorting="lv_Uc_Module_Sorting" 
        oniteminserting="lv_Uc_Module_ItemInserting" 
        DataKeyNames="EmpID">

            <LayoutTemplate>
                <table id="table_Lv_Layout" runat="server">
                    <tr id="tr_Table_Layout" runat="server">
                        <td id="td_Table_Layout" runat="server">
                            <table ID="itemPlaceholderContainer" runat="server" class="th_ItemTemplate">
                                <tr id="tr_Table_IphContainer" runat="server" style="">
                                    <th id="th1_Table_IphContainer" runat="server">
                                        <asp:Label ID="lb1_Table_IphContainer" runat="server" Text=""></asp:Label>
                                        <asp:ImageButton ID="imb1_Table_IphContainer" CommandArgument="EmpID" CommandName="Sort" ImageUrl="~/Images/asc.png" runat="server" />
                                    </th>
                                    <th id="th2_Table_IphContainer" runat="server">
                                        <asp:Label ID="lb2_Table_IphContainer" runat="server" Text=""></asp:Label>
                                        <asp:ImageButton ID="imb2_Table_IphContainer" CommandArgument="EmpName" CommandName="Sort" ImageUrl="~/Images/asc.png" runat="server" />
                                    </th>
                                    <th id="th3_Table_IphContainer" runat="server">
                                        <asp:Label ID="lb3_Table_IphContainer" runat="server" Text=""></asp:Label>
                                    </th>
                                    <th id="th4_Table_IphContainer" runat="server">
                                        <asp:Label ID="lb4_Table_IphContainer" runat="server" Text=""></asp:Label>
                                    </th>
                                    <th id="th5_Table_IphContainer" runat="server">
                                        <asp:Label ID="lb5_Table_IphContainer" runat="server" Text=""></asp:Label>
                                    </th>
                                    <th id="th6_Table_IphContainer" runat="server">

                                    </th>
                                </tr>
                                <tr ID="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr id="tr_Validate_Table_Layout" runat="server">
                        <td id="td_Validate_Table_Layout" runat="server" style="text-align: center;background-color: #CCCCCC;">
                            <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGEditTmp" />
                            <asp:ValidationSummary ID="ValidationSummary2" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGInsertTmp" />
                        </td>
                    </tr>
                </table>
                <br />
                <asp:DataPager ID="lv_DataPager" runat="server" PagedControlID="lv_Uc_Module" PageSize="5" OnPreRender="lv_DataPager_PreRender">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="true" ShowLastPageButton="true" />
                        <asp:TemplatePagerField>
                            <PagerTemplate>
                                <span style="color:Maroon;">Records:
                                    <%# Container.StartRowIndex >= 0 ? (Container.StartRowIndex + 1) : 0 %>
                                    -
                                    <%# (Container.StartRowIndex + Container.PageSize) > Container.TotalRowCount ? Container.TotalRowCount : (Container.StartRowIndex + Container.PageSize)%>
                                    of
                                    <%# Container.TotalRowCount %>
                                    <span style="color:Red;">
                                    OR  
                                    </span>
                                    <span style="color: Blue;">
                                    Page 
                                    <%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>
                                    of
                                    <%# Math.Ceiling((double)Container.TotalRowCount / Container.PageSize) %>
                                    </span>
                                </span>
                            </PagerTemplate>
                        </asp:TemplatePagerField>
                    </Fields>
                </asp:DataPager>
            </LayoutTemplate>

            <ItemTemplate>
                <tr class="tr_ItemTemplate">
                    <td>
                        <asp:Label ID="lb_ItemTemp1" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Label ID="lb_ItemTemp2" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Label ID="lb_ItemTemp3" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Label ID="lb_ItemTemp4" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Label ID="lb_ItemTemp5" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Button ID="btn_Edit" runat="server" CommandName="Edit" Text="" CssClass="btn_Edit" CausesValidation="True" />
                        <asp:Button ID="btn_Delete" runat="server" CommandName="Delete" Text="" CssClass="btn_Delete" CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this item?');" />
                    </td>
                </tr>
            </ItemTemplate>

            <EditItemTemplate>
                <tr style="background-color:#008A8C;color: #FFFFFF;">
                    <td>
                        <asp:Label ID="lb_ItemTemp1" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp1" runat="server" Text='' ValidationGroup="VGEditTmp" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="td_EditTemp1" ErrorMessage="Name is required" ValidationGroup="VGEditTmp" Display="None" ></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="td_EditTemp1" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGEditTmp" Display="None"></asp:RegularExpressionValidator>
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp2" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp3" runat="server" Text='' ValidationGroup="VGEditTmp" />
                        <asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="td_EditTemp3" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval(18-50)!" ValidationGroup="VGEditTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp4" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Button ID="btn_Update" runat="server" CommandName="Update" Text="Update" ValidationGroup="VGEditTmp" />
                        <asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                    </td>
                </tr>
            </EditItemTemplate>

            <InsertItemTemplate>
                <tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
                    <td>
                        &nbsp;
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp1" runat="server" Text='' ValidationGroup="VGInsertTmp" />
                        <asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="td_EditTemp1" ErrorMessage="Name is required" ValidationGroup="VGInsertTmp" Display="None"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="td_EditTemp1" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGInsertTmp" Display="None"></asp:RegularExpressionValidator>
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp2" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp3" runat="server" Text='' ValidationGroup="VGInsertTmp" />
                        <asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="td_EditTemp3" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval(18-50)!" ValidationGroup="VGInsertTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
                    </td>
                    <td>
                        <asp:TextBox ID="td_EditTemp4" runat="server" Text='' />
                    </td>
                    <td>
                        <asp:Button ID="btn_Insert" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="VGInsertTmp" />
                        <asp:Button ID="btn_Cancel" runat="server" CommandName="Cancel" Text="Clear" CausesValidation="false" />
                    </td>
                </tr>
            </InsertItemTemplate>

        </asp:ListView>

Не могли бы вы подсказать мне, как преодолеть эту проблему. Я использую asp.net и c #. Ценю ваше внимание.

1 Ответ

0 голосов
/ 12 января 2012

Я думаю, вам нужно изменить свойство InsertItemPosition вашего GridView с InsertItemPosition="LastItem" в InsertItemPosition="FirstItem" в вашей декларации.

...