Click here to Skip to main content
15,886,963 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi
While Using the alias names of each row I am getting multiple Duplicate Grids on scrolling Down the grid

What I have tried:

<pre>SELECT T.DeptID As DeptID  ,SUM(CASE WHEN datepart(yyyy,T.DOJ) between 2005 and 2017 and T.Status =0 then 1 else 0 END) As TotalHeadCount, 
SUM(CASE when T.DOJ >= cast('2017-01-12' as datetime) and T.Status =0  then 1 else 0 END) As NewJoinees1, 
SUM (CASE When T.deactivate>= Cast('2017-01-12' as datetime) and T.Status =0 then 0 else 1 END) As Resigned1, 
SUM(CASE WHEN T1.Tobehired IS NULL THEN '0' ELSE Tobehired END) AS Tobehired ,
SUM(CASE WHEN  T1.Openposition IS NULL THEN '0' ELSE Openposition END)  As Openposition ,T1.Status As Status
FROM EmployeeDetails T  LEFT JOIN RecruitmentDetails1 T1 on T.DeptID = T1.DeptID
Where T.Status=0
GROUP BY T.DeptID
       , T1.Tobehired
       , T1.Openposition
       , T1.Status 



<pre><asp:View ID="View2" runat="server">

                                    <br />
                                    <br />
                                    <table align="center" class="table table-bordered">
                                        <tr valign="middle">
                                            <td>Month
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlMonths" runat="server"></asp:DropDownList>

                                                <%--<asp:TextBox ID="txtmonth" runat="server"></asp:TextBox>--%>
                                            </td>
                                            <td>Year
                                            </td>
                                            <td>
                                                <%--<asp:TextBox ID="txtyear" runat="server"></asp:TextBox>--%>
                                                <asp:DropDownList ID="ddlyear" runat="server"></asp:DropDownList>
                                            </td>
                                            <td>
                                                <asp:Button ID="btnGenerate" runat="server" CssClass="btn btn-wide btn-dark-grey" Text="Find" OnClick="btnGenerate_Click" />
                                            </td>
                                        </tr>
                                    </table>
                                    <table align="center">
                                        <tr>
                                            <td>
                                                <span id="printcontent1">
                                                    <asp:DataList ID="DataListHeadCount" HorizontalAlign="Center" DataSourceID="SqlDataSourceHeadCount" runat="server">
                                                        <ItemTemplate>
                                                            <table align="center" class="table table-bordered">
                                                                <tr align="center">
                                                                    <td>Data
                                                                    </td>
                                                                    <td>COUNT
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>NEW JOINEES
                                                                    </td>
                                                                    <td align="center">
                                                                        
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>RESIGNATIONS
                                                                    </td>
                                                                    <td align="center">
                                                                       
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>TOTAL HEADCOUNT
                                                                    </td>
                                                                    <td align="center">
                                                                        
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                            <div>
                                                            <table >
                                                                <tr>
                                                                    <td
                                                                        colspan="7" align="center">
                                                                        <%=ddlMonths.Text %><%=ddlyear.Text %></td>
                                                                </tr>
                                                               

                                                                <tr>
                                                                    <td>
                                                                        <asp:GridView ID="grdvEmployeeLeaveUpdate" runat="server" DataKeyNames="" 
                         class="table table-bordered table-striped table-hover" DataSourceID="SqlDataSourceHeadCount"   
                        OnRowDataBound="grdvEmployeeLeaveUpdate_RowDataBound"  AutoGenerateColumns="False" Width="100%"  
                        OnRowDeleting="grdvEmployeeLeaveUpdate_RowDeleting"
                        OnRowEditing="grdvEmployeeLeaveUpdate_RowEditing"
                        OnRowUpdating="grdvEmployeeLeaveUpdate_RowUpdating"
                        OnRowCancelingEdit="grdvEmployeeLeaveUpdate_RowCancelingEdit"
                         OnPageIndexChanging="grdvEmployeeLeaveUpdate_PageIndexChanging">
                        
                        <Columns>
                            <asp:BoundField DataField="DeptID"  HeaderText="Cost Center" ReadOnly="true"   />
                            <asp:BoundField DataField="TotalHeadCount" HeaderText="HeadCount" ReadOnly="true"    />
                            <asp:BoundField DataField="NewJoinees1" HeaderText="Additions" ReadOnly="true"   />
                            <asp:BoundField DataField="Resigned1" HeaderText="Separations" ReadOnly="true"   />
                            <asp:BoundField DataField="Tobehired" HeaderText="To Be Hired"  ControlStyle-Width="80px" />
                            <asp:BoundField DataField="Openposition" HeaderText="Open Position" ControlStyle-Width="80px" />
                            <asp:BoundField DataField="Status" HeaderText="Status"  ControlStyle-Width="80px" />
                            <asp:CommandField HeaderText="Update" ShowEditButton="True" ControlStyle-Width="80px" />
                            
                        </Columns>
                        <HeaderStyle></HeaderStyle>
                    </asp:GridView>

                                                                    </td>

                                                                </tr>

                  </table>
                                                                </div>
                                                            
                                                        </ItemTemplate>
                                                    </asp:DataList>
                                                </span>
                                            </td>
                                        </tr>
                                    </table>

                                    <table align="center">
                                        <tr valign="middle" align="center">
                                            <td align="center">
                                                <asp:Button ID="btnExport" runat="server" CssClass="btn btn-wide btn-dark-grey" Text="Export To Excel" OnClick="btnExport_Click" />
                                                <input id="Button2" class="btn btn-wide btn-dark-grey" onclick="return doprintcontent1();" type="button" value="Print Page" />
                                            </td>
                                        </tr>
                                    </table>
                                    <asp:SqlDataSource ID="SqlDataSourceHeadCount" runat="server" ConnectionString="<%$ ConnectionStrings:TimeSheetConnectionString2 %>"
                                        SelectCommandType="StoredProcedure" SelectCommand="Sampe4"
                                        UpdateCommand="UPDATE RecruitmentDetails1 SET Tobehired = @Tobehired, Openposition = @Openposition, Status=@Status WHERE DeptID = @DeptID">
                                        <SelectParameters>
                                            <asp:ControlParameter ControlID="ddlMonths" Name="months" Type="Int32" />
                                            <asp:ControlParameter ControlID="ddlyear" Name="years" Type="Int32" />
                                        </SelectParameters>
</asp:SqlDataSource>
</asp:View>
Posted
Updated 2-May-17 23:18pm

1 solution

You need to give every row it's own id or class. Simple fix is to put your table inside a container. Also best way is to set the container with a height and width as fixed height.

 <div id="my-table">

       //add table here

</div>
 
Share this answer
 
Comments
Member 12605293 3-May-17 5:30am    
Hi Sir Thanks fro the reply, I am getting your point by the way I have removed the Datalist part and now the duplicate Grid is not comming but the Values in first table is not populationg

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900