bob jason tiamsic

bob jason tiamsic

  • NA
  • 12
  • 7.7k

MultiLevel Grid View- Panel does not show

Apr 3 2014 7:48 PM
hello everyone, can you check my codes, my panel does not show though I check the result of the query I have in Sql server and it does have a result.

Here's my asp.net code for making the gridviews and the panel:

<asp:View ID="View2" runat="server">
                     <div class="inside5px" style="border:1px solid #fdb814; border-top:10px solid #fdb814;">
                        
                        <asp:GridView ID="EmpLeaveAppGV2" runat="server" CssClass="datagrid gridfont" AutoGenerateColumns="False" GridLines="none" 
                            CellPadding="4" ForeColor="#333333" EmptyDataText= "No current record found in the database." Width="868px" DataKeyNames="EmployeeNo" OnRowDataBound="gv2RowBound_GetLeaveDetails"><%-- DataKeyNames="EmployeeNo" OnRowDataBound="gv2RowBound_GetLeaveDetails" --%>
                            <EmptyDataRowStyle  BackColor="#E3EAEB" BorderColor="#1C5E55" HorizontalAlign="Center" />
                            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
                            <RowStyle BackColor="#E3EAEB" BorderColor="#E3EAEB" BorderWidth="1px"  />
                            <SelectedRowStyle BackColor="#CCCCCC" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#1C5E55" HorizontalAlign="Left" Height="20px" ForeColor="White" BorderColor="#1C5E55" BorderWidth="1px"  />
                            <AlternatingRowStyle BackColor="White" BorderColor="#E3EAEB" BorderWidth="1px" />

                            <Columns>
                            
                              
                                <asp:TemplateField HeaderStyle-BorderStyle="None" ItemStyle-Width="10" ItemStyle-CssClass="tRight" ItemStyle-HorizontalAlign="left">
                                    <ItemTemplate> 
                                      <img Title= "View Details" style="cursor: pointer" src="../Images/plus.png/"/>
                                      <asp:HiddenField ID="lblEmpId" runat="server" Value='<%# Bind("EmployeeNo") %>'/>
                                        
--panel for 2nd grid view 
<asp:Panel ID="pnlRegDetails" runat="server" Style="display:none;"> <!-- Plus sign panel -->
                                         <div style="padding:2px 2px 2px 2px;">
                                         <div style="border:1px solid #E0AB72;">

                                         <!-- grid for leave details -->
                                          <asp:GridView ID="gv2LeaveDetails" CellPadding="2" runat="server" ShowHeader="True" Width="1132px" GridLines="both" CssClass = "ChildGrid"> <%-- OnRowDataBound="gv2RowBound_GetAddLeaveDetails" DataKeyNames = "LeaveTranId" --%>
                                            <EmptyDataRowStyle  BackColor="#E3EAEB" BorderColor="#1C5E55" HorizontalAlign="Center" ForeColor="#4B6C9E" />
                                            <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />              
                                            <Columns>
                                               

                                               <asp:TemplateField HeaderText="Leave Type" HeaderStyle-HorizontalAlign="left" HeaderStyle-BorderStyle="None" ItemStyle-HorizontalAlign="Left" ItemStyle-Width="100">
                                                    <ItemTemplate>
                                                         <asp:Label ID="lblLeaveType" runat="server" Text='<%# Bind("LeaveType") %>'></asp:Label>
                                                    </ItemTemplate>
                                                  </asp:TemplateField>




and here's my code in Code Behind

////details of second grid
    protected void gv2RowBound_GetLeaveDetails(object sender, GridViewRowEventArgs e)
    {
        int cutoffid = getCutOffID(cboCutOffSelect.SelectedValue);
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            //find gv2LeaveDetails
            string empNo = EmpLeaveAppGV2.DataKeys[e.Row.RowIndex].Value.ToString(); //getEmpNo DataKey based on DataKeyName from the found control (gvLeaveDetails)
            GridView gv2LeaveDetails = e.Row.FindControl("gv2LeaveDetails") as GridView;
            
           
            using (SqlConnection con = new SqlConnection(DAO.ConnectionString))
            {
                con.Open();
                string sql;

                empApproved.EmployeeNo, empApproved.EmpName, empApproved.LeaveType , empApproved.WholeOrPartial, empApproved.Status, empApproved.DateApproved, empApproved.Remarks, empApproved.ApprovedBy,empApproved.ApplicationDate";
                
                /////this query is filter data by EmployeeNo
                sql = "Select empApproved.LeaveTranId, empApproved.EmployeeNo, empApproved.EmpName, empApproved.LeaveType,empApproved.ApplicationDate ,MIN(empDate.LeaveDate) as LeaveDateFrom, MAX(empDate.LeaveDate) as LeaveDateTo, empApproved.WholeOrPartial, empApproved.Status, empApproved.DateApproved, empApproved.Remarks,(Select (empInfo.LastName + ', ' + empInfo.FirstName) from dbo.EmpPersonalInfo empInfo where empInfo.UserName = empApproved.ApprovedBy) as ApprovedBy from ISMPayroll.dbo.EmpLeaveDates empDate inner join ISMPayroll.dbo.viewEmployeeLeaveDatesForApproved empApproved on empDate.LeaveTranId = empApproved.LeaveTranId where empDate.LeaveDate BETWEEN (Select ISMPayroll.dbo.CutOff_Period.CutOff_From from ISMPayroll.dbo.CutOff_Period where CutOffID='" + cutoffid + "') AND (Select ISMPayroll.dbo.CutOff_Period.CutOff_to from ISMPayroll.dbo.CutOff_Period where CutOffID='" + cutoffid + "') and empApproved.Status ='Approved' and empApproved.EmployeeNo='" + empNo + "' group by empApproved.LeaveTranId,empApproved.EmployeeNo, empApproved.EmpName, empApproved.LeaveType , empApproved.WholeOrPartial, empApproved.Status, empApproved.DateApproved, empApproved.Remarks, empApproved.ApprovedBy,empApproved.ApplicationDate order by empApproved.EmpName";
                
                
                SqlDataAdapter da = new SqlDataAdapter(sql, con);
                DataTable dt = new DataTable();
                da.Fill(dt);


                gv2LeaveDetails.DataSource = dt;
                gv2LeaveDetails.DataBind();
            }
        }
    }