高手请赐教:
问题如下所描述:
自定义控件结构如下,小弟想在红色字体处穿插代码块,用以获取条目数。不知如何处理?
<Jans:ZDataGrid id="dg1" runat="server" method="Jans.Site.Service.Core.Framework.Business.RoleTabSite.dg1DataBind"
size="14"><table width="100%" cellpadding="2" cellspacing="0" class="dataTable">
<tr ztype="pagebar">
<td colspan="<%=map.Counts+2%>">${PageBar}</td>
</tr>
</tr>
</table>
</Jans:ZDataGrid>
后台定义一个PUBLIC变量呀。
--kankan
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestP.ascx.cs" Inherits="TestP" %>
<table width="100%" cellpadding="2" cellspacing="0" class="dataTable">
<tr ztype="pagebar">
<td colspan="<%= Map.Counts +2%>">
${PageBar}</td>
</tr>
</table>
--back
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 TestP : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
public static class Map
{
public static int Counts = 3;
}
}
<td colspan="<%=(map.Counts+2)%>">${PageBar}</td>
asp.net webform不允许你在view上干那么多事儿
你可以在cs中写一个方法
或者转投asp.net mvc的怀抱,它让你从容的面对view,可以在view中应用各种逻辑操作(当然,我并不推荐你这么做)如果你玩过asp,php,jsp会有更深刻的了解。