Advertisement

[x]
Attachment Details

How to format form (table) in a datalist

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.7
Hi,

I have a problem of displaying/formating data bound by a datalist control. In my
table, I have fields like BusinessName and CustomerName... that based on different cratiria I
might display them or not like I show in example 1 and 2.
I would like to make my output to look like example 2a without blank lines in between rows...
Please help me.

Thanks in advance.

Example 1:
--------------
Req:25
BusinessName:ABC
CustomerName:David Green
Mobile #: 959-981-9779             Acct#: 4569994
Contact#: 949-191-4444       Alternate #: 994-454-2000
--------------------------------------------------
--------------------------------------------------

Example 2:
--------------
Req:26
        ? --- blank line
        ? --- blank line  
Mobile #: 999-999-9999             Acct#: 4565451
Contact#: 999-191-5454       Alternate #: 994-454-1515
--------------------------------------------------
--------------------------------------------------

Example 2a:
--------------
Req:26
Mobile #: 999-999-9999             Acct#: 4565451
Contact#: 999-191-5454       Alternate #: 994-454-1515
....


Here is some html code:

<body>
  <form id="form1" runat="server">
    <div>
   
<asp:DataList ID="dlForm" runat="server" Height="80px" Width="488px">

<ItemTemplate>
     <table border="0" width="579" height="1210">
      <tr>
            <td height="24" width="569" colspan="2">
                <font face="Verdana" size="1" color="#3671b1">Request Number:</font><font face="Verdana" size="1"><%# DataBinder.Eval(Container.DataItem, "ReqNo") %></font></td>
      </tr>
      <tr>
            <td height="58" width="273">
                <font face="Verdana" size="1"><!--Business Name:--><%#CheckForBusinessName(Container.DataItem("BusinessName"))%></font>
                <p><font face="Verdana" size="1"><!--Customer Name:--><%#CheckForFName(Container.DataItem("FName"))%>      <%#CheckForLName(Container.DataItem("LName"))%></font></p>
            <p><font face="Verdana" size="1"><!--Mobile #:--><%# MobileNotEqualRefund(Container.DataItem("MobileNo"), Container.DataItem("ActionRequired"))%></font></p>
            <p><font face="Verdana" size="1"><!--Contact #:--><%# DisplayContactNo(Container.DataItem("ContactNo"), Container.DataItem("ActionRequired"), Container.DataItem("MobileNo"))%></font></td>
            <td height="58" width="290">&nbsp;
                <p><font face="Verdana" size="1"><!--Acct #:--><%# AccountNotEqualRefund(Container.DataItem("AccountNo"), Container.DataItem("ActionRequired"))%></font></p>
            <p><font face="Verdana" size="1"><!--Alternate #:--><%# DisplayAlternateNo(Container.DataItem("AlternateNo"), Container.DataItem("ActionRequired"), Container.DataItem("MobileNo"))%></font></td>
      </tr>
      ...
</table>


</ItemTemplate>
</asp:DataList>
    </div>
    </form>
   
</body>

--------------------------------------

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not IsPostBack Then
           
        BindData()
       
        End If

 End Sub

 Sub BindData()

        Dim strConnString As String = "server=*******;database=******;uid=*****;pwd=*****"
        Dim objConn As New SqlConnection(strConnString)

        Dim SQL1 As String

        SQL1 = "select ......"

        Dim cmd As New SqlCommand(SQL1, objConn)
        Dim reader As SqlDataReader

        objConn.Open()

        reader = cmd.ExecuteReader
        dlForm.DataSource = reader
        dlForm.DataBind()
        reader.Close()
        objConn.Close()

    End Sub


 Public Function CheckForBusinessName(ByVal BusinessName As String)

        Select Case BusinessName
            Case "Unknown"
                Return ""
            Case "None"
                Return ""
            Case "none"
                Return ""
            Case "n/a"
                Return ""
            Case Else
                Return ("<font face='Verdana' size='1' color='#3671B1'>" & "Business Name: </font>" & BusinessName)
                'Return BusinessName
        End Select
    End Function

    Public Function CheckForFName(ByVal FName As String) As String

        Select Case FName
            Case "Unknown"
                Return ""
            Case "n/a"
                Return ""
            Case "999999999"
                Return ""
            Case Else
                Return ("<font face='Verdana' size='1' color='#3671B1'>" & "Customer Name: </font>" & FName)
        End Select

    End Function

    Public Function CheckForLName(ByVal LName As String) As String

        Select Case LName
            Case "Unknown"
                Return ""
            Case "n/a"
                Return ""
            Case "999999999"
                Return ""
            Case Else
                Return LName
        End Select

    End Function
Related Solutions
Related Solutions
 
Loading Advertisement...
 

Rank: Guru

Expert Comment by DotNetThinker:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by vetukna:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 

Rank: Guru

Accepted Solution by DotNetThinker:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Author Comment by vetukna:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
Loading Advertisement...
20080924-EE-VQP-40 / EE_QW_2_20070628