【发布时间】:2012-03-31 06:20:54
【问题描述】:
这是我现在正在做的事情:
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridViewUserScraps_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="MakeComments" runat="server" TextMode="MultiLine"></asp:TextBox>
<asp:Button ID="btnPost" Text="Comment" runat="server" CommandName="Comment" CommandArgument='<%#Eval("ScrapId")%>' />
<asp:GridView ID="GridView2" runat="server">
<%--this GridView2 showing comments--%>
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridViewUserScraps_RowDataBound(object sender, GridViewRowEventArgs e)
{
GridView gv = new GridView();
gv = (GridView)row.FindControl("GridView2");
//getting data to bind child gridview.
gv.DataSource = td;
gv.DataBind();
}
所以,在单击 GridView1 按钮时,我正在更新数据库并同时获取数据,这没有任何问题。但为此我必须绑定/刷新父(GridView1)Gridview,因为有近 50 行,所以过程相当缓慢。我正在寻找的是; 我只想更新或刷新 GridView2 以显示添加的 cmets。
【问题讨论】:
-
您想何时刷新 cmets?在单击按钮期间?
-
@PraVn OP 想要更新用户点击按钮所在行的 GridView2。
-
因为我在 GridView1 的 OnRowDataBound 事件中绑定了 GridView2,所以我必须更新 GridVeiw1,此后只有我得到更新的数据。是的,我想在 Button Click 上刷新它。