<%@ OutputCache Duration="60" VaryByParam="*" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FormDataChangeA.ascx.cs" Inherits="_controls_FormDataChangeA" %>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr style="display:none;">
<td colspan="2" style="background-image: url(_images/cate.gif); height: 24px; font-weight: bold; color: #cc0000; font-size: 9pt;" align="left">
┣ <asp:Label ID="lblFormName" runat="server"></asp:Label></td>
</tr>
</table>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderColor="#E0E0E0"
BorderStyle="None" BorderWidth="1px" CellPadding="4" GridLines="None"
ShowHeader="False" Width="100%" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="FormDataId" Visible="False" />
<asp:TemplateField>
<ItemTemplate>
<img src="../_images/small.gif" width=5px height=5px ></img>
<asp:HyperLink ID="linkCaption" runat="server" NavigateUrl='<%# FormatLink()+"?id=" + Eval("FormDataId") %>'
Text='<%# Convert.ToString(Eval("Caption")) %>' ToolTip='<%# Eval("Caption") %>' Target="_blank"></asp:HyperLink>
<asp:Label ID="lbl" runat="server" Text='<%# Eval("PostedDate") %>' Visible="false"></asp:Label>
<asp:Image ID="imageNew" runat="server" Visible="False" />
</ItemTemplate>
<ItemStyle Font-Size="9pt" HorizontalAlign="Left" Width="80%" />
</asp:TemplateField>
<asp:BoundField DataField="PostedDate" DataFormatString="{0:yyyy-MM-dd}" HtmlEncode="False" Visible="False">
<ItemStyle Font-Size="9pt" HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
<RowStyle BorderColor="#404040" BorderStyle="Dotted" BorderWidth="1px" />
</asp:GridView>
<asp:Label ID="Label1" runat="server" Font-Size="9pt" ForeColor="Silver" Height="160px"
Text=" " Width="100%"></asp:Label>
<table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
<tr>
<td align="right">
<asp:HyperLink ID="linkMore" runat="server" Font-Size="9pt" Visible="False"> </asp:HyperLink></td>
</tr>
</table>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _controls_FormDataChangeA : System.Web.UI.UserControl
{
public int FormId
{
set
{
ViewState["FormDataListControl_FormId"] = value;
}
get
{
return Convert.ToInt32(ViewState["FormDataListControl_FormId"]);
}
}
public int Count
{
set
{
ViewState["FormDataListControl_Count"] = value;
}
get
{
return Convert.ToInt32(ViewState["FormDataListControl_Count"]);
}
}
public int FontLength
{
set
{
ViewState["FormDataListControl_FontLength"] = value;
}
get
{
return Convert.ToInt32(ViewState["FormDataListControl_FontLength"]);
}
}
public string LinkName
{
set
{
ViewState["FormDataListControl_linkName"] = value;
}
get
{
return Convert.ToString(ViewState["FormDataListControl_linkName"]);
}
}
public int FormClass
{
set
{
ViewState["FormDataListControl_FormClass"] = value;
}
get
{
return Convert.ToInt32(ViewState["FormDataListControl_FormClass"]);
}
}
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
BindData();
}
catch (Exception exp)
{
Response.Redirect("Error.aspx");
}
}
private void BindData()
{
int formId = Convert.ToInt32(ViewState["FormDataListControl_FormId"]);
int count = Convert.ToInt32(ViewState["FormDataListControl_Count"]);
int formClass = Convert.ToInt16(ViewState["FormDataListControl_FormClass"]);
linkMore.NavigateUrl = "../ArticleList.aspx?id=" + formId;
Junking.Publication.Form form = new Junking.Publication.Form();
DataSet ds = form.Load(formId);
if (ds.Tables[0].Rows.Count > 0)
{
lblFormName.Text = Convert.ToString(ds.Tables[0].Rows[0]["FormName"]);
}
Junking.Publication.FormData formData = new Junking.Publication.FormData();
DataSet dsList = new DataSet();
switch (formClass)
{
case 1:
dsList = formData.LoadSub(formId, count); // formid,
break;
case 2:
dsList = formData.LoadTop(formId, count);// parentid,
break;
case 3:
dsList = formData.LoadListCount(formId, count); // parentid formid
break;
case 4:
dsList = formData.LoadSub1(formId, count); // parentid,formdataid
break;
case 5:
dsList = formData.LoadTop1(formId, count); // formid,formdataid
break;
case 6:
dsList = formData.LoadListCount1(formId, count); // parentid formid,formdataid
break;
default:
dsList = formData.LoadSub(formId, count);
break;
}
if (dsList.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = dsList.Tables[0];
GridView1.DataBind();
Label1.Visible = false;
}
else
{
GridView1.Visible = false;
Label1.Visible = true;
}
}
public string FormatLink()
{
return Convert.ToString(ViewState["FormDataListControl_linkName"]);
}
public string FormatString(string value, int length)
{
string r = String.Empty;
if (value.Length > length)
r = value.Substring(0, length) + "...";
else
r = value;
return r;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int fontlength = Convert.ToInt32(ViewState["FormDataListControl_FontLength"]);
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink hy = (HyperLink)e.Row.Cells[1].FindControl("linkCaption");
Label lbl = (Label)e.Row.FindControl("lbl");
Image image = (Image)e.Row.FindControl("imageNew");
TimeSpan ts = new TimeSpan();
ts = DateTime.Now - Convert.ToDateTime(lbl.Text);
int daysCount = Convert.ToInt32(ts.Days.ToString());
if (daysCount < 1)
{
image.Visible = true;
image.ImageUrl = "../_images/n.gif";
hy.Text = FormatString(hy.Text, fontlength-3);
}
else
{
hy.Text = FormatString(hy.Text, fontlength);
}
}
}
}