CS页面中定义一个 public比如前台是<%=i%>CS 中就是 public int i 这样i就能在前台显示了
解决方案 »
- js函数引用
- try catch 是否影响运行效率? 一会儿就结贴。在线。
- 关于GridView1View中checkbox的选中问题
- 再问个问题:怎么在程序里动态控制让某个列在不同状态下可以编辑,或者禁止编辑(GridView).
- asp.net页面套Form表单,远程提交怎么做,我的做法不行
- GridView的又一个问题?
- 这一行代码在整个程序是起什么用的
- 有支持C#,.aspx语法加亮的编辑器么?除了Visual Studio?
- DataGrid能否显示成树状
- 如何在.cs 代码文件中调用用户控件?
- 安装NET2003时有问题,会弹出请插入光盘Visual Studio.NET.....
- vb.net做了个网站
public int i = 10;//必须是public
在pageload里执行
{
this.Page.DataBind()
}前台就<%#i%>
<table>
<tr><td id="mytd" runat="server"></td></tr></table>
后台:
public class 页面名 : PageBase
{
protected System.Web.UI.HtmlControls.HtmlTableCell mytd;
...
private void Page_Load(object sender, System.EventArgs e)
{
string ss;
ss = "<table>";
for(int i=0;i<20;i++)
{
ss += "<tr>"+i.ToString()+"</tr>";
}
ss += "</table";
this.mytd.InnerHtml = ss;
}
...
}
我把代码稍微贴一下:
.aspx 中:<% int j;
for(j=1;j<=daysInMonth;j++) { %>
<td bgcolor="#FFFFFF">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" align="center" bgcolor="#E8EEF7" style="height: 19px" >
<<%=j%>
</td>
</tr>
<tr>
<td valign="top" style=" height: 20px">
<asp:DataList ID="ShowMonthList" runat="server" >
<ItemTemplate>
<tr><td>
<%# DataBinder.Eval(Container.DataItem,"releaseTime")%>
</td>
<td><%# DataBinder.Eval(Container.DataItem,"contents") %></td>
</tr>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</td>
<%} %>
我这里的j是日历中的每一天,我想根据这个天数查询数据库的记录
把所有需要的标记放到字符串里面
string show;
for(j=1;j<=daysInMonth;j++)
{
show=“ <td bgcolor="#FFFFFF"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">”
show+=“<tr><td colspan="2" align="center" bgcolor="#E8EEF7" style="height: 19px" >
<<%=j%>”
……
show+=“<td valign="top" style=" height: 20px">”+取到的数据+“</td>”
……
}
最后把这个字符串打出来就ok了
可以用 response.write(show)在页面上;或则在要显示的地方 放个label在处理完数据后直接把label.text=show 也可以
tablecolumn td = new tablecolumn();
tablerow tr = new tablerow():textbox txt = new textbox();
txt.text = "hahaha";td.controls.add(txt)
tr.controls.add(td);
tb.controls.add(tr);_________________________
大概这样子