ASP按钮不显示的Windows 2012 Server上
我已经在一个GridView显示信息的应用程序:ASP按钮不显示的Windows 2012 Server上
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Font-Size="X-Small" OnRowDataBound="GridView1_RowDataBound"
PageSize="100" DataSourceID="SiteDataSource1" Width="100%">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="20" Position="TopAndBottom" />
<RowStyle CssClass="itemstyle" />
<HeaderStyle CssClass="headerstyle" />
<AlternatingRowStyle CssClass="altstyle" />
<Columns>
<asp:BoundField DataField="Description" HeaderText="Description" ReadOnly="True" SortExpression="Description">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="Identifier" HeaderText="Identifier" ReadOnly="True" SortExpression="Identifier">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="State" HeaderText="State" ReadOnly="True" SortExpression="State">
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="HostHeaderValue" HeaderText="Host Header Value" ReadOnly="True"
SortExpression="HostHeaderValue" />
<asp:BoundField DataField="IPAddress" HeaderText="IP Address" ReadOnly="True" SortExpression="IPAddress" />
<asp:BoundField DataField="Port" HeaderText="Port" ReadOnly="True" SortExpression="Port" />
<asp:BoundField DataField="SSLPort" HeaderText="SSL Port" ReadOnly="True" SortExpression="SSLPort" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" CausesValidation="false" CommandName="Control"
OnClick="Button_Clicked" Text="Control" Width="50" />
</ItemTemplate>
<ItemStyle Width="50px" />
</asp:TemplateField>
</Columns>
按钮的状态设置
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView entry = e.Row.DataItem as DataRowView;
if (entry != null)
{
switch (entry["State"] as string)
{
case "Stopped":
e.Row.Cells[2].BackColor = System.Drawing.Color.OrangeRed;
e.Row.Cells[2].ForeColor = System.Drawing.Color.White;
((Button)e.Row.Cells[7].Controls[1]).Text = "Start";
((Button)e.Row.Cells[7].Controls[1]).ForeColor = System.Drawing.Color.Green;
((Button)e.Row.Cells[7].Controls[1]).CommandArgument = entry["Site"] as string + "|" + entry["Description"] as string;
break;
case "Running":
e.Row.Cells[2].BackColor = System.Drawing.Color.Honeydew;
((Button)e.Row.Cells[7].Controls[1]).Text = "Stop";
((Button)e.Row.Cells[7].Controls[1]).ForeColor = System.Drawing.Color.Red;
((Button)e.Row.Cells[7].Controls[1]).CommandArgument = entry["Site"] as string + "|" + entry["Description"] as string;
break;
default:
e.Row.Cells[2].BackColor = System.Drawing.Color.Yellow;
e.Row.Cells[7].Text = "";
break;
}
上Windows 2008服务器按钮显示没有问题,但是当我用gridview查看此页面时,Windows 2012服务器上带有按钮的列为空。有没有人见过这个?任何帮助/建议非常感谢。
回答:
事实证明,有一个数据库查询在设置按钮后验证服务器在管理组中,atm查询返回null,所以这就是为什么该按钮被禁用。感谢所有的建议/帮助
以上是 ASP按钮不显示的Windows 2012 Server上 的全部内容, 来源链接: utcz.com/qa/266187.html