Solved

ASP.net 2.0 Custom formatting of results inside a FormView.

Posted on 2008-10-15
3
548 Views
Last Modified: 2012-05-05
I'm doing a query such as the following:
SELECT TOP(3) ItemName FROM Items WHERE merchantCategory='Travel' ORDER BY NEWID()
to display inside a formview. I would like the results to display as follows:
Item1 | Item2 | Item3
However, they're automatically going to display like this inside the formview:
Item1
Item2
Item3
How do I custom format the results using the formview?
0
Comment
Question by:jumpstart0321
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
maXXXeE earned 250 total points
ID: 22729145
if your main purpose is to display, then you should use listView, since it will give better control over presentation
0
 
LVL 7

Expert Comment

by:maXXXeE
ID: 22729167
Sorry, I meant DataList not listView
you can specify RepeatDirection="Horizontal" , for horizontal alignment of data
0
 
LVL 1

Assisted Solution

by:ashishkaithi
ashishkaithi earned 250 total points
ID: 22729184
you can use it like this.
you shud knw abt HEADER_TEMPLATE and FOOTER_TEMPLATE

I m attaching the code.
U must convert form view into template mode .
By default Item template get displayed. I m attaching only that code .
It will make u'r FORMVIEW READONLY.
Let me know if u've any difficulty.
Regards
Ashish

<asp:FormView ID="FormView1" runat="server" DataSourceID="testFormView">

        <HeaderTemplate>

           <table ><th>USERNAME</th><th>ROLL</th>

        </HeaderTemplate> 

            <ItemTemplate>

             

                    <tr>

                        <td>

                            <asp:Label ID="UserNameLabel" runat="server" Text='<%# Bind("UserName") %>' />

                        </td>

                        <td>

                          

                            <asp:Label ID="UserIdLabel" runat="server" Text='<%# Bind("UserId") %>' />

                        </td>

                    </tr>

              

            </ItemTemplate>

          <FooterTemplate></table></FooterTemplate>

        </asp:FormView>

        <asp:SqlDataSource ID="testFormView" runat="server" 

            ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" 

            SelectCommand="SELECT [UserName], [UserId] FROM [Login]">

        </asp:SqlDataSource>

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now