-1

I am new to asp.net and even though I have been successfully developing some decent pages that access backend SQL server using C# code behind, I have run into a problem that I need some nudge in the right direction on.

I need to be able to display records from a SQL datasource (could be displayed using SQLDataSource method OR using a dataReader OR using a gridview data fill) onto a page but I need other information displayed above and below the returned record. Its best if I show an example:


<horizontal seperator line>
Customer ID
                Customer Name
                Customer Address
                City, ST

                COLUMNS FOR THE RETURNED RECORD DATA
                THE ACTUAL RECORD DATA

                OTHER DYNAMICALLY CALCULATED DATA BELOW THE RECORDS

<horizontal seperator line>
And this repeats for every record that is returned

For the life of me, I can't find determine what view, template, or even best data binder or data source control it is that I need to use to make this happen.
Thanks for anyone's assistance in advance. dell

dellbingham
  • 59
  • 1
  • 5

4 Answers4

1

If a datatable or gridview won't do, you can always use a Repeater or a Listview. In the template, you can have all the controls you want in there.

You probably need a repeater similar to this:

<asp:Repeater runat="server" ID="repeater1">
        <ItemTemplate>
            <hr/>
            <asp:Label runat="server" ID="labelCustomerId" />
            <div style="padding-left:150px">
                <asp:Label runat="server" ID="labelCustomerName" />
                <asp:Label runat="server" ID="labelCustomerAddress" />
                <asp:Label runat="server" ID="labelCityState" />    
            </div>
            <asp:GridView runat="server" ID="gridViewRecordData">
                <!--define columns & footer calculations here -->
            </asp:GridView>
            <hr/>
        </ItemTemplate>
 </asp:Repeater>

You can use the same ItemTemplate if you chose a ListView

Ed B
  • 6,028
  • 3
  • 26
  • 35
  • This is the best way I have seen thus far. that is if I am interpreting correctly. I am assuming that somehow I would display exactly one record of the returned dataset where you have the – dellbingham Nov 17 '11 at 22:49
0

Repeated is the best control. but in repeater you need to write code for Paging, Sorting...etc functiontly.

If you don't want to code for paging, sorting then go for GridView.

Pankaj Agarwal
  • 11,191
  • 12
  • 43
  • 59
0

Try a ListView control. It lets you use templates to define how records, groups of records, etc. show up. For example you could define a template for your customer contact info, then a template for your records and other data.

Becuzz
  • 6,846
  • 26
  • 39
0

You can accomplish this easily with a ListView. This article has a display of product information that's a lot like your layout -- horizontal lines between repeated sections.

I also like Scott Gu's tutorial, though the data layout (catalog images) is a little different from yours. Still, there's some good screenshots, and it also demos a Linq to SQL data source, which is a popular choice.

DOK
  • 32,337
  • 7
  • 60
  • 92