感谢有益的网站.. gridview的代码如下:
<asp:GridView ID="gridmem" runat="server" AutoGenerateColumns="False" CellPadding="3" GridLines="Vertical" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" DataKeyNames="UserName" style="z-index: 1; left: 88px; top: 32px; width: 255px; text-align: left; position: absolute; height: 217px" >
<AlternatingRowStyle BackColor="#DCDCDC" />
<Columns>
<asp:BoundField DataField="UserName" HeaderText="User Name" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:CommandField ShowSelectButton="true" />
<asp:TemplateField HeaderText="Activing"><ItemTemplate>
<asp:LinkButton ID="Activating" runat="server" Text="Active" BackColor="Yellow" OnClick="Activating_Click" ClientIDMode="Static" /> <asp:LinkButton ID="deActive" Text="DeActive" BackColor="yellow" runat="server" Visible="false" OnClick="deActive_Click" /></ItemTemplate></asp:TemplateField>
</Columns>
</asp:GridView>
// code .cs:
protected void Activating_Click(object sender, EventArgs e)
{
gridmem.TemplateControl.FindControl("deActive").Visible = true;
}
但错误正在上线;
错误:对象引用未设置为对象的实例。
为什么会出现错误???