网格视图在我们点击添加按钮i之前显示数据,e在刷新不工作之前:解决了 [英] Grid view to display data as soon as we hit add button i,e before refreshing not working: solved

查看:67
本文介绍了网格视图在我们点击添加按钮i之前显示数据,e在刷新不工作之前:解决了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

有人可以帮我吗。

我有一个Gridview,显示从文本框输入的新数据和下拉列表添加按钮。但是一旦我们刷新或回发

页面就会显示。

Hi
Can some one help me please.
I have a Gridview which displays the new data entered from the text box and drop downlist with a add button .But it displays once we refresh or postback the
page.

<asp:GridView 
            ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" 
            CellPadding="4" DataKeyNames="SettingId" DataSourceID="SqlDataSource5" 
            ForeColor="#333333" GridLines="None" Height="55px" Width="753px">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:BoundField DataField="SettingType" HeaderText="SettingType" 
                    SortExpression="SettingType" Visible="False" />
                <asp:BoundField DataField="Auth" HeaderText="Auth" 
                    SortExpression="Auth" Visible="False" />
                <asp:BoundField DataField="Group" HeaderText="Group" 
                    SortExpression="Group" Visible="False" />
                <asp:BoundField DataField="Branches" HeaderText="Branches" 
                    SortExpression="Branches" />
                <asp:BoundField DataField="Category" HeaderText="Category" 
                    SortExpression="Category" />
                <asp:BoundField DataField="Bind" HeaderText="Bind" 
                    SortExpression="Bind" Visible="False" />
                <asp:BoundField DataField="Subject" HeaderText="Subject" 
                    SortExpression="Subject" />
                <asp:BoundField DataField="Year" HeaderText="Year" 
                    SortExpression="Year" />
                <asp:BoundField DataField="Id" HeaderText="Id" 
                    InsertVisible="False" ReadOnly="True" SortExpression="Id" 
                    Visible="False" />
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:Button ID="Button1" runat="server" CausesValidation="false" onclientclick="return confirm('Are you sure you want to delete this Setting?');"
                            CommandName="Delete" Text="" />
                    </ItemTemplate>
                    <ControlStyle CssClass="btnstyle" Height="30px" Width="30px" />
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#2461BF" />
            <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" 
                HorizontalAlign="Left" />
            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#EFF3FB" />
            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#F5F7FB" />
            <SortedAscendingHeaderStyle BackColor="#6D95E1" />
            <SortedDescendingCellStyle BackColor="#E9EBEF" />
            <SortedDescendingHeaderStyle BackColor="#4870BE" />
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
            ConnectionString="<% %>" 
            DeleteCommand="DELETE FROM Setting WHERE (Id = @Id)" 
            
            SelectCommand="SELECT SettingType, Code, Group, Branch, Category, Binding, Subject, Issues, Year, Id FROM Setting WHERE (SettingType = 'something')">
            <DeleteParameters>
                <asp:Parameter Name="Id" />
            </DeleteParameters>
        </asp:SqlDataSource>







我想让网格尽快显示插入的数据点击添加没有回发或刷新。




I want the grid to show the data inserted as soon as i hit add without post back or refreshing.

推荐答案

<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
    </asp:scriptmanager>
<asp:updatepanel xmlns:asp="#unknown">
            ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <contenttemplate>
         
// you will have your grid here

</contenttemplate>
<asp:asyncpostbacktrigger controlid="btnUpload" eventname="Click" />
</asp:updatepanel>







代码落后:










in code behind:

on button click event

GridView1.DataBind();
   UpdatePanel1.Update();


这篇关于网格视图在我们点击添加按钮i之前显示数据,e在刷新不工作之前:解决了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆