0

やあ皆さん、私が画面に表示したいパネルをハードコーディングする前に、次のようにしました。

<asp:Panel ID="Panel1" runat="server" CssClass="PrintHeader" HorizontalAlign="Center">
                <div style="margin-left:10px;margin-bottom:10px;text-align:center;">
                    <span style="font-size:22px;border-bottom:double 1px black">Construction Contracts</span><br /><br />
                    <span style="font-size:12px;">317 Upper Road, Mountblock, Liverpool, Co. Such&Such BT70 6HJ</span><br /><br />
                    <span style="font-size:16px;">Invoice Number: <%: this.CurrentInvoiceName %></span><br />
                    <span style="font-size:16px;">MEASUREMENT FOR PAYMENT</span><br />
                    <span style="font-size:12px;">V.A.T. No. 851 119 123</span>
                </div>
            </asp:Panel>

次に、 boundField 請求書の現在のレイアウト を持つ GridView を使用して、テーブルから詳細を取得し、画面に表示しました。問題は、レイアウトに少し問題があることです。私は使用しています:

<asp:GridView ID="GridView1" CssClass="PrintHeader" HorizontalAlign="Center" runat="server" Width="100px" AllowSorting="true" AutoGenerateColumns="false" DataSourceID="GridDataSource"> 
                <Columns>

                        <asp:BoundField DataField="id" HeaderText="InvoiceInfoID" ReadOnly="True" SortExpression="InvoiceInfoID" /> 
                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />  
                        <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="Address" />  
                        <asp:BoundField DataField="County" HeaderText="County" SortExpression="County" />  
                        <asp:BoundField DataField="Postcode" HeaderText="Postcode" SortExpression="Postcode" />
                        <asp:BoundField DataField="Invoice Number" HeaderText="Invoice Number" SortExpression="Invoice Number"/>   
                        <asp:BoundField DataField="Info" HeaderText="Info" SortExpression="Info" />   
                        <asp:BoundField DataField="VAT Number" HeaderText="VAT Number" SortExpression="VAT Number"/>  

                                </Columns>

                                <PagerStyle CssClass="footer"/>        
                                <PagerTemplate>
                                    <asp:GridViewPager runat="server" />
                                </PagerTemplate>
                                <EmptyDataTemplate>
                                    There are currently no details to display.
                                </EmptyDataTemplate>

                </asp:GridView>

                 <asp:SqlDataSource ID="GridDataSource" runat="server"   
                            ConnectionString="<%$ConnectionStrings:ClarkesTest4FromMaster1ConnectionString %>"  
                            SelectCommand="SELECT id, [Name], [Address], [County], [Postcode], [Invoice Number], [Info], [VAT Number] FROM [Invoice Info] ORDER BY [Name]" >
                 </asp:SqlDataSource> 

これは次のようになります。 ここに画像の説明を入力

テーブルを変更して、テーブルなしで以前のレイアウトとして表示し、各行を横にではなく重ねて表示したいと思います。show column = falseなどを試しました。また、パネルを使用してみましたできない、

私が望むものを達成するために編集する必要がある属性を誰かアドバイスしてもらえますか?

ありがとうございました

編集:リピーターを試したすべての返信に感謝します:

それで:

<asp:Panel ID="Panel2" runat="server" CssClass="PrintHeader" HorizontalAlign="Center">
                        <asp:Repeater ID="InvoiceHeader" DataSourceID="GridDataSource" runat="server">
                            <ItemTemplate>
                                <asp:Label ID="Name" runat="server" Text='<%Eval("invoice_Info")%>'> </asp:Label>
                                </tr>
                                </td>
                            </ItemTemplate>
                        </asp:Repeater>
                    </asp:Panel>
 <asp:SqlDataSource ID="GridDataSource" runat="server"   
                            ConnectionString="<%$ConnectionStrings:ClarkesTest4FromMaster1ConnectionString %>"  
                            SelectCommand="SELECT id, [Name], [Address], [County], [Postcode], [Invoice Number], [Info], [VAT Number] FROM [Invoice Info] ORDER BY [Name]" >
                 </asp:SqlDataSource> 

次に、コードビハインドで:

 ClarkeDBDataContext db = new ClarkeDBDataContext();

        invoice_Info =
        (from invoiceInfo in db.Invoice_Infos
         select invoiceInfo).FirstOrDefault();

        Header.DataBind();
The page displays: <%Eval("invoice_Info")%>

誰かが私がどこで間違っているのかアドバイスできますか?

ありがとう

4

2 に答える 2

0

<%Eval("invoice_Info")%>使用の代わりに<%#Eval("invoice_Info")%>

于 2013-03-02T10:30:09.480 に答える
0
 <asp:GridView ID="grdid" runat="server" AutoGenerateColumns="false" EmptyDataText="No records" ShowHeader="false">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                 <div style="margin-left:10px;margin-bottom:10px;text-align:center;">
                <span style="font-size:22px;border-bottom:double 1px black">Construction Contracts</span><br /><br />
                <span style="font-size:12px;">317 Upper Road, Mountblock, Liverpool, Co. Such&Such BT70 6HJ</span><br /><br />
                <span style="font-size:16px;">Invoice Number: <%#Eval("CurrentInvoiceName")%></span><br />
                <span style="font-size:16px;">MEASUREMENT FOR PAYMENT</span><br />
                <span style="font-size:12px;">V.A.T. No. 851 119 123</span>
            </div>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

このようにコードを使用します。グリッドを適切な列値でバインドします。

于 2013-01-29T11:35:42.823 に答える