日期:2014-05-17 浏览次数:20567 次
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { System.Data.DataTable dataTable1 = new System.Data.DataTable("BlogUser"); System.Data.DataRow dr; dataTable1.Columns.Add(new System.Data.DataColumn("UserId", typeof(System.Int32))); dataTable1.Columns.Add(new System.Data.DataColumn("UserName", typeof(System.String))); for (int i = 0; i < 8; i++) { dr = dataTable1.NewRow(); dr[0] = i; dr[1] = "【孟子E章】" + i.ToString(); dataTable1.Rows.Add(dr); } GridView1.DataSource = dataTable1; GridView1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title></title> <script type="text/javascript"> function xx(btn) { b = btn.parentNode; while (b.tagName != "TR") b = b.parentNode; b.cells[0].getElementsByTagName("div")[0].style.display = b.cells[0].getElementsByTagName("div")[0].style.display == "none" ? "" : "none"; } </script> </head> <body> <form id="form1" runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="UserId"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Panel ID="x" runat="server"> <asp:TextBox ID="replay" runat="server"></asp:TextBox> </asp:Panel> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <ItemTemplate> <asp:Button ID="y" runat="server" OnClientClick="xx(this);return false;" Text="显示隐藏测试"></asp:Button> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </form> </body> </html>