我想使用 Design 更改 gridview 的标题文本。
<asp:BoundField HeaderText="">
我在javascript中创建了一个变量并根据条件初始化变量防御,然后我尝试在此处调用该变量,如下所示:
<asp:BoundField HeaderText="Text Here" DataField="slno" >
在这里,我使用存储在一个变量名称中的“text here”字符串。我想使用那个变量
我的代码:
<script type="text/javascript" language="javascript">
/// <summary>
/// TO ACCESS COOKIE VARIABLE
/// </summary>
var flag;
var ca = document.cookie.split('=');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ',') c = c.substring(1);
}
if (c != '' && c != null) {
flag = c;
}
else {
flag = 1;
}
//*********************************************
if (flag == 1) {
var name_lbl = "Hai";
}
else if (flag == 2) {
var name_lbl = "How are you?";
}
</script>
//------------------------------------------------
</asp:Content>
<form id="form1" runat="server">
</table>
<div style="overflow: auto; height: 99%;" id="divTable">
<table><tr><td>
<label for='field ID'> <b><input type="text" id="kilist_lbl" size="20" style="border: none; height:20px" readonly/></b> </label> <br />
</td></tr></table>
<asp:GridView ID="gvareadetails" runat="server"
CssClass="mGrid" AutoGenerateColumns="False">
<Columns>
<%-- here is the problem when assigning ID to headerText label --%>
<asp:BoundField HeaderText='sss' DataField="slno" >
<ItemStyle Width="5%" />
</asp:BoundField>
</Columns>
</asp:GridView>
</div>
</form>
<script type="text/javascript" language="javascript">
document.getElementById('sss').value = name_lbl;
</script>
</asp:Content>
任何人都有任何建议如何实现这一目标..