Solved

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

Posted on 2008-10-15
3
567 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

636 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