数据绑定button,点击产生对应项事件
|
另
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "Show_Hidden")
{
Label txt = (Label)e.Item.FindControl("ProductNameLabel");
if (ViewState["IsVisible"] != null && (bool)ViewState["IsVisible"])
{
txt.Visible = true;
ViewState["IsVisible"] = false;
}
else
{
ViewState["IsVisible"] = true;
txt.Visible = false;
}
}
}
<asp:Button ID="Button1" runat="server" Text="Button" CommandName="Show_Hidden" />
更多在这里
http://www.cnblogs.com/ilovejolly/archive/2006/12/15/593555.html