zoukankan      html  css  js  c++  java
  • 今天实现了用按钮后台动态实现了 table里面内容的显示和隐藏 在实现过程中了解了updatepanel的简单的用法

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <link href="Style/Style.css" rel="Stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div style="text-align:center;">
    
       <asp:ScriptManager ID="ScriptManager1" runat="server">
           </asp:ScriptManager>
        <asp:updatepanel ID="Updatepanel1" runat="server">
       <ContentTemplate>
           
          <asp:Button ID="Button2" runat="server" Text="Button" 
                onclick="Button2_Click1" />
        <table id="table1" align="center" runat="server">
        <tr>
        <td>
        
    
            <asp:GridView class="HeaderStyle"  align="center" BorderStyle="Solid" 
                CellPadding="3" PageSize="5" ID="GridView1" runat="server"  
                AutoGenerateColumns="False" Width="100%">
            <Columns>
            <asp:TemplateField HeaderText="论文题目" SortExpression="lwtitle">
            <ItemTemplate>
                <asp:Label ID="Label1" runat="server" Text='<%#bind("lwtitle") %>'></asp:Label>
            </ItemTemplate>
             </asp:TemplateField>
             <asp:TemplateField HeaderText ="论文内容" SortExpression="contxt">
             <ItemTemplate>
             <asp:Label ID="Label1" runat="server" Text='<%#bind("contxt") %>' ></asp:Label>
             </ItemTemplate>
              </asp:TemplateField>
               
              <asp:TemplateField HeaderText="编辑" ShowHeader="False">
             <ItemTemplate>
                 <asp:Button ID="Button1" runat="server" Text="编辑"  CommandName="edita" CommandArgument='<%#bind("lwid")%>'/>
             
             </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="删除" ShowHeader="False">
             <ItemTemplate>
              <asp:Button ID="Button1" runat="server" Text="删除"  CommandName="del" CommandArgument='<%#bind("lwid")%>'/>
             
            </ItemTemplate>
             </asp:TemplateField>
            </Columns>
            
            </asp:GridView>
            </td>
        </tr>
         </table>
           
    
           
       
         </ContentTemplate>
         </asp:updatepanel>
       
        </div>
       </form>
    </body>
    </html>
    <%--前台代码 注意在使用updatapanel之前 引入
    <asp:ScriptManager ID="ScriptManager1" runat="server">
           </asp:ScriptManager>--%>

    后台代码

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data;
    public partial class Default5 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }
        public void bind()
        {
            string str = "select * from thesis";
           
            GridView1.DataSource = SQLHelper.GetDataSet(str);
            GridView1.DataBind();
        
        }
       
            
        
        protected void Button2_Click1(object sender, EventArgs e)
        {
            if (table1.Visible == false)
            {
                table1.Visible = true;
    
    
            }
            else if(table1.Visible==true)
            {
    
                table1.Visible = false;
    
            }
        }
    }
  • 相关阅读:
    东南亚互联网创业哪些领域比较有前景?
    2021最新最实用.NET Core笔试题附答案
    2021UpdateC#.NET笔试题基础篇
    Ubuntu下 安装MiniGUI
    MiniGUI 如何显示繁体字
    Android 基础一 TextView,Style样式,Activity 传值,选择CheckBox 显示密码
    【玩转开源】BananaPi R2 —— 第一篇 Openwrt安装
    JAVA面对对象(二)——继承、方法的覆写
    JAVA面对对象(一)——封装
    JAVA关键字及作用
  • 原文地址:https://www.cnblogs.com/haihang/p/2813167.html
Copyright © 2011-2022 走看看