在CS文件中的变量,ASPX文件中调用得到的是一个空值?
CS中的文件
protected void Page_Load(object sender, EventArgs e)
{
Session[ "systemdelete "] = "索引 ";
}
ASPX:
<body>
<form id= "form1 " runat= "server ">
<table style= "width: 450px ">
<tr>
<td style= "width: 640px ">
<table >
<tr>
<td vAlign= "top " style= "height: 225px "> <asp:datagrid id= "dgCard " runat= "server " DataKeyField= "userid " AutoGenerateColumns= "False " AllowPaging= "True " OnSelectedIndexChanged= "dgCard_SelectedIndexChanged " >
<Columns>
<asp:ButtonColumn Text= ' <%=Session[ "systemdelete "]%> ' CommandName= "Delete ">
<ItemStyle Font-Names= "宋体 " Width= "30px "> </ItemStyle>
</asp:ButtonColumn>
</Columns>
这样执行竞然是空的,请问是不是BODY中的代码执行在CS代码前呢?
------解决方案--------------------这样能取到Session[ "systemdelete "]吗?
还是public string a然后再在页面上取吧!
------解决方案--------------------用楼上的方法,public string strText;
生成html是在cs代码之后
------解决方案--------------------在datagrid里面?你的datagrid绑定数据没有
如果没有绑定数据肯定没有值
而且应该用 <%#吧
<asp:ButtonColumn Text= ' <%#Session[ "systemdelete "]%> ' CommandName= "Delete ">
<ItemStyle Font-Names= "宋体 " Width= "30px "> </ItemStyle>
</asp:ButtonColumn>