日期:2014-05-18  浏览次数:20458 次

局部刷新gridview的问题
html页:
HTML code


<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;</div>
       
        <cc1:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" runat="server">
        </cc1:ScriptManager>
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        <cc1:UpdatePanel ID="UpdatePanel1" runat="server" >
            <ContentTemplate>
                <asp:GridView ID="GridView1" runat="server" Height="205px" Width="554px" AutoGenerateColumns="False" DataKeyNames="id" OnRowEditing="GridView1_RowEditing" >
                    <Columns>
                        <asp:BoundField DataField="userName" HeaderText="userName" SortExpression="userName" />
                        <asp:BoundField DataField="passWord" HeaderText="passWord" SortExpression="passWord" />
                        <asp:BoundField DataField="userClass" HeaderText="userClass" SortExpression="userClass" />
                        <asp:BoundField DataField="id" HeaderText="id" InsertVisible="False" ReadOnly="True" SortExpression="id" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SalesDBConnectionString %>"
                    SelectCommand="SELECT [userName], [passWord], [userClass], [id] FROM [admin]"></asp:SqlDataSource>
                <cc2:TimerControl ID="TimerControl1" runat="server">
                </cc2:TimerControl>
               
       <%-- <cc2:TimerControl ID="TimerControl1" runat="server" Interval="1000" OnTick="Timer1_Tick">
        
        </cc2:TimerControl>--%>
       
            </ContentTemplate>
           
        </cc1:UpdatePanel>
        &nbsp;
    </form>
     <script type="text/xml-script">
        <page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
            <references>
            </references>
            <components>
            </components>
        </page>
    </script>
</body>




后台.cs
C# code

protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            showdb();
        }
    }

    private void showdb()
    {
         SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["strcon"]);
         SqlDataAdapter da = new SqlDataAdapter("select * from admin", con);
         DataSet ds = new DataSet();
         da.Fill(ds,"users");

         this.GridView1.DataSource = ds.Tables["users"];
         this.GridView1.DataBind();
    }
 protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        this.GridView1.EditIndex = e.NewEditIndex;
        showdb();
    }



为什么没有实现自动刷新来更新gv里的数据呢???

------解决方案--------------------
OnTick="Timer1_Tick"
这个事件代码呢?
------解决方案--------------------
看看你后台的Timer1_Tick 这个函数!
laber控件可以有html标签也有Eval绑顶么?解决办法