Click here to Skip to main content
14,775,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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();
}
Posted
Comments
   
After binding, try to give focus inside timer click event.
DominoBoy 26-Jun-14 12:20pm
   
how ?
and also it lose entered value !

1 solution

using
if(!ispostback)
{
}
on page load event.... hope it will help u
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900