Solved

Add space to datagrid

Posted on 2006-07-18
1
206 Views
Last Modified: 2008-02-01
I really need some help on this.  

I have a datagrid that displays the records from a query.

 I would like to add a space each time the date changes in the datagrid.  The query should display 3 dates with a space in between each date.

Thank you

CODE ******************************************************

<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace=" System.Data.SqlClient" %>
<HTML>
     <HEAD>
          <title>Health District Quick Add Hours</title>
          <link href="styles.css" rel="stylesheet">
               <script runat="server" language="VB">
               

               
               
dim objCmd as New SqlCommand
Dim objRdr as SqlDataReader
Dim objConn as New SqlConnection("Server=xxxxxx;uid=xx;pwd=xxxx;Database=xxxxxxx;")
Dim strCmd As String

 
     
     
     
Sub Page_Load()
     If Not IsPostBack Then
          BindData()
     End If
End Sub

Sub BindData()
dim getusername as string
Dim MyName As String = Request.ServerVariables("LOGON_USER")
response.write(MyName)
objConn.Open()
   Dim currentdate As DateTime = Now.AddDays(-4)
     Dim strCurrentdate As String = currentdate.ToString("yyyy.MM.dd") 'ANSI format the date
     objCmd.CommandText = "select eh.recordid, firstname + ' ' +  lastname as name, timein, timeout, description from employeehours as eh inner join employeelist as el on eh.employeeid = el.employeeid inner join masterjobcodelist as mjc on eh.jobcode = mjc.jobcode where firstname = 'Justine' and lastname = 'Cleary' and timein  > CONVERT(datetime, '" & strCurrentdate & "', 102) order by timein "

objCmd.Connection = objConn
objRdr = objCmd.ExecuteReader()
          dgAddressBook.DataSource = objRdr

     dgAddressBook.DataBind()
     objRdr.Close()
     objConn.Close()
End Sub




               </script>
     </HEAD>
     <body>
          <form runat="server">
               <table width="100%" border="0" cellspacing="0" cellpadding="0" background="Images/header_bg.gif">
                    <tr>
                         <td><img src="Images/header_top1.gif" width="450" height="142"></td>
                    </tr>
               </table>
               <table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                         <td width="157"></td>
                         <td></td>
                    </tr>
               </table>
               <table width="100%" border="0" cellspacing="0" cellpadding="10">
                    <tr>
                         <td valign="top" width="160">
                              <!-- HyperLink Controls for navigation -->
                              <img src="Images/book_closed.gif" width="16" height="16" alt="+"><asp:HyperLink NavigateUrl="index.aspx" runat="server" Text="Home" ID="Hyperlink1" /><br>
                              <img src="Images/book_closed.gif" width="16" height="16" alt="+"><asp:HyperLink NavigateUrl="quickaddhours.aspx" runat="server" Text="Edit/Add Hours" ID="Hyperlink2"></asp:HyperLink><br>
                              <img src="Images/book_closed.gif" width="16" height="16" alt="+"><asp:HyperLink NavigateUrl="weeklyhours.aspx" runat="server" Text="Review Hours" ID="Hyperlink4" /><br>
                              <!-- End HyperLink Controls -->
                         </td>
                         <td valign="top">
                              <h1>Quick Edit Hours</h1>
                              <p><asp:DataGrid id="dgAddressBook" runat="server" AutoGenerateColumns="false" CellPadding="4" GridLines="None"
                                        DataKeyField="recordID">
                                        <ItemStyle Font-Name="Arial" Font-Size="10pt" ForeColor="#000000" />
                                        <HeaderStyle Font-Name="Arial" Font-Size="10pt" Font-Bold="true" BackColor="#003366" ForeColor="#FFFFFF" />
                                        <AlternatingItemStyle Font-Name="Arial" Font-Size="10pt" BackColor="#CCCCCC" />
                                        <Columns>
                                             <asp:HyperLinkColumn DataNavigateUrlField="recordid" DataNavigateUrlFormatString="javascript:var test = window.open('popup.aspx?recordid={0}', null, 'width=400,height=300');"
                                                  DataTextField="recordid" HeaderText="Edit Hours"></asp:HyperLinkColumn>
                                             <asp:BoundColumn DataField="timein" HeaderText="Time In" ReadOnly="true" />
                                             <asp:BoundColumn DataField="timeout" HeaderText="Time out" ReadOnly="true" />
                                             <asp:BoundColumn DataField="description" HeaderText="Description" ReadOnly="true" />
                                        </Columns>
                                   </asp:DataGrid></p>
                         </td>
                    </tr>
               </table>
          </form>
     </body>
</HTML>


0
Comment
Question by:running32
[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
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17133678
1) Use a DataTable instead of an SqlDataReader
2) Add blank rows to the DataTable
3) Re-bind

Bob
0

Featured Post

Technology Partners: 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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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 explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

632 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