0

Hey guys so where before I was hard coding the panel I wanted to display on screen with:

<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>

which produced: Current Layout of invoice I then used a GridView with boundField, to pull across the details from the table and display them on sreen..Trouble is i'm having a little difficulty with the layout. I'm using:

<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> 

and this looks like: enter image description here

I would like to change the table to display as my previous layout, without the table, and each row on top of each other, not beside it, i've tried show column=false and stuff like that, also tried using a panel which cant be done,

Can anyone please advise what attribute i need to edit in order to achieve what I want?

Thank you

EDIT: Thanks for all the replies everyone i've tried the repeater:

so:

<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> 

then in code behind:

 ClarkeDBDataContext db = new ClarkeDBDataContext();

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

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

could someone advise where i am going wrong?

Thank ye

John
  • 3,965
  • 21
  • 77
  • 163
  • Have a single column inside Griview and bind the data and give the ItemStyle-HorizontalAlign="Center" for the Template Field and make the Gridview boarder to 0,hope you will be get the previous format. – MahaSwetha Jan 29 '13 at 11:05
  • Thanks for that, tried it but to no avail – John Jan 29 '13 at 11:21

2 Answers2

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>

Use code in this way. Bind your grid with appropriate column values.

Arjun
  • 21
  • 1
0

In place of <%Eval("invoice_Info")%> use <%#Eval("invoice_Info")%>

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
Arjun
  • 21
  • 1