Grid with inner grid(collapsible show hide) and file
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Census.master" AutoEventWireup="true"
Inherits="Users_PlanDocument" CodeBehind="PlanDocument.aspx.cs" %>
<%@ Import Namespace="JulyUtilities" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentTitle" runat="Server">
Plan Document
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="Server">
<script src="../ClientScript/OnlineDocument.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="Server">
<div style="border: solid 0px red; padding: 10px 10px 10px 10px;">
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #fff;
border-bottom: solid 0px #cbcaca;">
<tr>
<td class="TableContainerMiddle">
<div style="width: 20px; float: left; padding-left: 5px;">
<img src="../App_Themes/<%=Session["CurrentTheme"] %>/Images/Icon/title_icon.png"
alt="" />
</div>
<div class="Title_CSS" style="padding-left: 30px;">
Plan Document Files
</div>
</td>
</tr>
<tr>
<td colspan="0" class="containerBorderLR">
<%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>--%>
<div style="padding: 10px 10px 10px 10px;">
<asp:GridView ID="gvPlanDocumentsInfo" Width="100%" GridLines="None" runat="server"
AutoGenerateColumns="False" CssClass="mGridDataRequest" AlternatingRowStyle-CssClass="alt"
AllowPaging="True" DataKeyNames="PlanDocId" PageSize="10" EmptyDataText="Record Not Available"
OnPageIndexChanging="gvPlanDocuments_PageIndexChanging" OnRowDataBound="gvPlanDocumentsInfo_RowDataBound"
PagerStyle-CssClass="gridViewPager">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<a href="javascript:switchViews('div<%# Eval("PlanDocId") %>', 'one');">
<img id="imgdiv<%# Eval("PlanDocId") %>" alt="Click to show/hide orders" border="0"
src="../App_Themes/<%=Session["CurrentTheme"] %>/Images/Icon/minus-2.png" />
</a>
</ItemTemplate>
<HeaderStyle Width="4%" />
<ItemStyle Width="4%" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Project Type">
<ItemTemplate>
<a href="javascript:switchViews('div<%# Eval("PlanDocId") %>', 'one');"><span id="imgdiv<%# Eval("PlanDocId") %>">
<%# Eval("ProjectType")%></span> </a>
<asp:Image ID="Image1" ImageUrl="~/Images/new.gif" runat="server" Visible='<%# Eval("HasNewFile") %>' />
</ItemTemplate>
<HeaderStyle Width="20%" />
<ItemStyle Width="20%" />
</asp:TemplateField>
<asp:BoundField DataField="SubType" HeaderText="Sub Type">
<HeaderStyle Width="18%" />
<ItemStyle Width="18%" />
</asp:BoundField>
<asp:BoundField DataField="ProjectDesc" HeaderText="Project Description" />
<asp:BoundField DataField="DateEffective" HeaderText="Effective Date" DataFormatString="{0:MM/dd/yyyy}">
<HeaderStyle Width="14%" />
<ItemStyle Width="14%" />
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td colspan="100%" style="border: solid 0px red;">
<div id="div<%# Eval("PlanDocId") %>" style="display: none; position: relative; left: 12px;">
<asp:GridView ID="gvPlanDocumentsFileInfo" Width="100%" GridLines="None" runat="server"
AutoGenerateColumns="False" CssClass="mGridDataRequest" AlternatingRowStyle-CssClass="alt"
EmptyDataText="Record Not Available">
<Columns>
<asp:TemplateField HeaderText="File Name">
<ItemTemplate>
<div style="width: 100%; border: solid 0px blue;">
<div style="width: 5%; height: 10px; float: left; border: solid 0px red;">
<img src='<%# clsStyle.GetIconSrcByExtension(System.IO.Path.GetExtension(Eval("FilePath").ToString())) %>'
alt="" />
</div>
<div style="border: solid 0px red; float: left; width: 95%">
<%-- <asp:HyperLink ID="lnkFileName" runat="server" NavigateUrl='<%# WebApp.GetClientPortalFilesUrl(Eval("FilePath").ToString()) %>'
Target="_blank" Text='<%# Eval("FileName").ToString().Replace("_", "-") %>'></asp:HyperLink>--%>
<asp:LinkButton ID="lnkFileName" runat="server" Text='<%# Eval("FileName").ToString().Replace("_", "-") %>'
CommandName='<%# Eval("FilePathID") %>' CommandArgument='<%# Eval("FilePath") %>'
OnClick="lnkFileName_Click" />
<%--<img id="img" src='<%# clsStyle.GetIconSrcByDate(Eval("DateUpload").ToString()) %>'
alt="" />--%>
<asp:Image ID="Image1" ImageUrl="~/Images/new.gif" runat="server" Visible='<%# Eval("HasNewFile") %>' />
</div>
</div>
</ItemTemplate>
<HeaderStyle Width="45%" />
<ItemStyle Width="45%" />
</asp:TemplateField>
<asp:BoundField DataField="FileDescription" HeaderText="File Description">
<HeaderStyle Width="30%" />
<ItemStyle Width="30%" />
</asp:BoundField>
<asp:BoundField DataField="FileCategory" HeaderText="File Category">
<HeaderStyle Width="25%" />
<ItemStyle Width="25%" />
</asp:BoundField>
</Columns>
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<PagerStyle CssClass="pgr" />
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<%-- </ContentTemplate>
</asp:UpdatePanel>--%>
<div style="padding-left: 102px; padding-bottom: 10px;">
</div>
<div style="padding: 10px 0 5px 0px;">
</div>
</td>
</tr>
<tr>
<td colspan="0" class="containerBottom" style="border-right: solid 0px red;">
</td>
</tr>
</table>
<script type="text/javascript">
$(document).ready(function () {
$('img[src=""]').css('display', 'none');
});
</script>
</div>
</asp:Content>
***************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using July.BusinessServiceLayer.Facades;
using July.BusinessServiceLayer.Entities;
using July.BusinessServiceLayer.Helpers;
using JulyUtilities;
public partial class Users_PlanDocument : BasePage
{
List<PlanDocument> planDocuments = new List<PlanDocument>();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindPlanDocument();
}
}
private void BindPlanDocument()
{
PlanDocumentService _planDocumentsService = new PlanDocumentService();
planDocuments = _planDocumentsService.GetAllPlanDocuments(Convert.ToInt32(Page.CurrentWebUser().CurrentPlan.PlanID));
var comparer = new EqualityComparerUtil<PlanDocument>((arg1, arg2) => { return arg1.PlanDocId.EqualsIgnoreCase(arg2.PlanDocId); },
(arg) => arg.PlanDocId.GetHashCode());
var distinct = planDocuments.Distinct(comparer);
gvPlanDocumentsInfo.DataSource = distinct.ToList();
gvPlanDocumentsInfo.DataBind();
}
protected void gvPlanDocuments_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvPlanDocumentsInfo.PageIndex = e.NewPageIndex;
BindPlanDocument();
}
protected void gvPlanDocumentsInfo_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView gv = e.Row.FindControl("gvPlanDocumentsFileInfo") as GridView;
var data = from f in planDocuments where f.PlanDocId == gvPlanDocumentsInfo.DataKeys[e.Row.RowIndex].Value.ToString() select f;
//var data = from f in planDocuments where f.PlanDocId == gvPlanDocumentsInfo.DataKeys[e.Row.RowIndex].Value.ToString() orderby f.DateEffective,f.HasNewFile descending select f;
gv.DataSource = data.ToList();
gv.DataBind();
}
}
protected void lnkFileName_Click(object sender, EventArgs e)
{
LinkButton lnkDownLoad = new LinkButton();
lnkDownLoad = (LinkButton)sender;
FileDownload fileDownload = new FileDownload();
fileDownload.FilePathID = Convert.ToInt32(lnkDownLoad.CommandName);
fileDownload.DownloadedBy = Convert.ToInt32(Page.CurrentWebUser().Contact.ContactId);
string path = lnkDownLoad.CommandArgument;
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
if (new FileDownloadService().InsertFileDownloadHistory(fileDownload))
{
Response.Clear();
Response.ContentType = "application/ms-word";
//Modified by Mamun Issue # 17 (Error: Found Duplicate Headers error in Chrome)
Response.AddHeader("Content-Disposition", "attachment; filename=\"" + lnkDownLoad.Text + "\"");
//End Issue # 17
Response.TransmitFile(path);
Response.End();
}
}
else
{
ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "FileDownload", "alert('This file does not exist.')", true);
}
}
}
// -------- Expand/Close row when click on button
function switchViews(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById('img' + obj);
var $currentTheme = $("input[id$='hidCurentTheme']");
var plusUrl = null;
var minusUrl = null;
plusUrl = '../App_Themes/' + $currentTheme.val() + '/Images/Icon/plus-2.png';
minusUrl = '../App_Themes/' + $currentTheme.val() + '/Images/Icon/minus-2.png';
if (div.style.display == "none") {
div.style.display = "inline";
if (row == 'alt') {
img.src = minusUrl; //"../Images/minus-2.gif";
mce_src = plusUrl; //"../Images/plus-2.gif";
}
else {
img.src = plusUrl;//"../Images/plus-2.gif";
mce_src = minusUrl; //"../Images/minus-2.gif";
}
img.alt = "Close to view other Plan";
}
else {
div.style.display = "none";
if (row == 'alt') {
img.src = plusUrl; //"../Images/plus-2.gif";
mce_src = plusUrl; //"../Images/plus-2.gif";
}
else {
img.src = minusUrl; //"../Images/minus-2.gif";
mce_src = minusUrl ;//"../Images/minus-2.gif";
}
img.alt = "Expand to show File";
}
}
No comments:
Post a Comment