Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

GridView data columns offset from Gridview Headers?

$
0
0

I have a simple dataset that fills 8 columns in a basic GridView.  I am using the default Headers and have set them as Sortable.

My issue is that the columns and headers are not in sync. 

Example:
 
              System Access Management Monitor           8/14 3:23 p
               Origin                     Current
Event  Owner  Location   Date     Owner  Location    Date      Status
        225    DK      PLN   8/2 11:13 A  DK      PLN    8/7 9:15A   Complete
        223    KLD     WDB   8/2 10:57 A  KLD     WNIA   8/2 11:02A  Complete
        217    TOD     WDB   8/2 8:49 A   TOD     WDB    8/4 12:00A  Complete
        115    TLP     WDB   7/10 12:27 P TLP     STP    7/10 12:00A   Hold

 

As you can see, the Event Column is blank, and should have the data that is under the first Origin Owner column.  The Header Row that has "Event Owner Location..." should be shifted to the right one column, OR, the data columns shifted to the left.

Here's my HTML:
<asp:GridView ID="gvMainEvents" runat="server" DataSourceID="EventSource1" CssClass="tableXBase"
AutoGenerateColumns="False" AllowPaging="True" HorizontalAlign="Center" AllowSorting="True" EmptyDataText="No records found!">
    <Columns>
         <asp:TemplateField ControlStyle-CssClass="tableXHead2">
              <HeaderTemplate>
                  <th colspan="6">System Access Management Monitor</th>
                  <th align="right" style="white-space:nowrap" ><%# DateTime.Now.ToString("M/d h:mmt").ToLower()%></th>
                  <tr class="tableXHead2">
                    <th></th>
                    <th colspan="3">Origin</th>
                    <th colspan="3">Current</th>
                  </tr>
              </HeaderTemplate>
         </asp:TemplateField>
         <asp:BoundField DataField="Event_ID" HeaderText="Event" SortExpression="Event_ID"/>
         <asp:BoundField DataField="O_Owner" HeaderText="Owner" SortExpression="O_Owner"/>
         <asp:BoundField DataField="O_Location" HeaderText="Location" SortExpression="O_Location"/>
         <asp:BoundField DataField="OE_Date" HeaderText="Date" SortExpression="OE_Date" DataFormatString="{0:M/d h:mt}"/>
         <asp:BoundField DataField="C_Owner" HeaderText="Owner" SortExpression="C_Owner"/>
         <asp:BoundField DataField="C_Location" HeaderText="Location" SortExpression="C_Location"/>
         <asp:BoundField DataField="C_Date" HeaderText="Date"   SortExpression="C_Date" DataFormatString="{0:M/d h:mt}"/>
         <asp:BoundField DataField="C_Status" HeaderText="Status" SortExpression="C_Status"/>
    </Columns>
    <HeaderStyle CssClass="tableXHead2" />
    <RowStyle CssClass="tableXRow" />
    <AlternatingRowStyle CssClass="tableXRowAlt" />
 </asp:GridView>

 and, my .CSS file:

.tableXBase
{
 /*border-color: #191970;  /* MidnightBlue */
 /*border-width:0;*/
 /*border:0;*/
 left:200;
 white-space:nowrap;
 background-color: Blue; /*#191970;  /* MidnightBlue */
 color:#191970;  /* GhostWhite #F8F8FF*/
 text-align:center;
 /*table-layout:auto;*/
}

.tableXHead1
{
    font-weight:bold;
    width:60%;
 text-align:center;
}

.tableXHead2
{
 background-color:#3CB371; /* ForestGreen */
 color:Blue;  /* MidnightBlue */
 font-size:medium;
 font-weight:bold;
 white-space:nowrap;
}

.tableXRow
{
 font-size:small;
 color:#191970;  /* MidnightBlue */
 background-color:#FFFAFA; /* snow */
 white-space:nowrap;
}

.tableXRow:hover
{
 background-color:yellow;
 cursor: pointer;
 color:green;
}

.tableXRowAlt
{
 font-size:small;
 color:#191970;  /* MidnightBlue */
 background-color:#87CEFA; /* LightSkyBlue*/
 white-space:nowrap;
}

.tableXRowAlt:hover
{
 color:green;
 background-color:yellow;
 cursor:pointer;
}
the SQL is a direct SELECT statement not doing anything tricky or cute, so I won't waste your time here...

Interesting sidenote here, the Sorting works for the appropriate header, it sorts the corresponding column even though the data column is not directly under the header column.

Any ideas?

Thanks,

KevDavDFW


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>