textBox失去对嵌套Gridview的关注 [英] textBox Lose focus on nested Gridview
本文介绍了textBox失去对嵌套Gridview的关注的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个嵌套的Gridview,父级用于Posts,Child用于评论,我想用时间间隔更新帖子和评论,所以我使用的是asp.net计时器,我的问题是在第一个Gridview丢失的TextBox当计时器Tick,我搜索了很多,可能的解决方案是从UpdatePanel中放置文本框,但在这种情况下我不能放出textBox。请帮帮我这里是我的代码
I have two nested Gridview that parent is for Posts and Child is for Comments, i want to update Post and Comments with a Time Interval so Im using an asp.net Timer, my problem is a TextBox that is in First Gridview lose focus when timer Tick, i Searched the web a lot, Possible solution was the put textbox out of UpdatePanel but in this situation i cant put out the textBox. please help me here is my code
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="Timer1" Interval="10000" OnTick="Timer1_Tick" runat="server"></asp:Timer>
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />
</Triggers>
<ContentTemplate>
<%--post GridView--%>
<asp:GridView ID="posts" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<%--Comments Gridview--%>
<asp:GridView ID="comments" runat="server"></asp:GridView>
<%--a Textbox and bUtton For sending new Comment--%>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
protected void Timer1_Tick(object sender, EventArgs e)
{
posts.DataSource = GetData();
posts.DataBind();
}
推荐答案
使用
if(!ispostback)
{
}
页面加载事件....希望它能帮到你
using
if(!ispostback)
{
}
on page load event.... hope it will help u
这篇关于textBox失去对嵌套Gridview的关注的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文