Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When i am clicking the edit button two times it is firing the event and also the editing field textbox is not focusing it automatically coming out of focus.

Actually this gridview was binded from the sqldatasource not from the method. Not only edit button update and cancel buttons as well. Where i am doing wrong can anyone suggest me. Here i used timer to load the data without refreshing the page

What I have tried:

<asp:UpdatePanel ID="up" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="tGVLoadData" EventName="Tick" />
    </Triggers>
    <ContentTemplate>
        <%-- Timer --%>
        <asp:Timer ID="tGVLoadData" runat="server" Interval="1000" OnTick="Timer1_Tick"></asp:Timer>
        <%-- GridView --%>
        <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" EmptyDataText="No Records Found" AllowPaging="True" GridLines="Vertical" AlternatingRowStyle-CssClass="alt" SkinID="gridviewSkin" Width="100%" CssClass="label" DataSourceID="DataSource" DataKeyNames="EmpID" OnRowEditing="gv_RowEditing" OnRowCancelingEdit="gv_RowCancelingEdit"                                          OnRowUpdating="gv_RowUpdating" OnRowDataBound="gv_RowDataBound"                                            ShowHeaderWhenEmpty="true" OnRowCommand="gv_RowCommand" EnableViewState="false">
            <AlternatingRowStyle CssClass="alt" />
            <Columns>
                <asp:TemplateField HeaderText="Simple">
                    <ItemTemplate>
                        <asp:Label ID="lblSimple" runat="server" Text='<%#Eval("Simple") %>' Width="40px"></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="txtSimple" runat="server" Text='<%#Eval("Simple") %>' Width="40px"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <%-- Buttons --%>
                <asp:TemplateField ItemStyle-Width="100px">
                    <ItemTemplate>
                        <%-- Edit --%>
                        <asp:Button ID="btnEdit" runat="server" Text="Edit" CssClass="btn btn-link text-center" ToolTip="Edit Details" CommandName="Edit" UseSubmitBehavior="false" OnClick="btnEdit_Click" CausesValidation="false" />
                        <%-- Approve --%>
                        <asp:Button ID="btnSimple" runat="server" Text="Approve" CssClass="btn btn-link text-center" ToolTip="Approve" OnClick="btnSimple" Enabled="false" />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:Button ID="btnUpdate" runat="server" Text="Update" CommandName="Update" CssClass="btn btn-link" UseSubmitBehavior="false" />
                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CssClass="btn btn-link" />
                    </EditItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

        <asp:SqlDataSource runat="server" ID="DataSource" ConnectionString='<%$ ConnectionStrings:DefaultConnection %>' SelectCommand="SELECT [EmpID] FROM [Emp_Table]"></asp:SqlDataSource>

    </ContentTemplate>
</asp:UpdatePanel>


Code Behind:
PageLoad Event
if(!IsPostBack)
{
   foreach (GridViewRow row in gv.Rows)
   {
       aspBtnEdit = ((Button)row.FindControl("btnEdit"));
       btn = ((Button)row.FindControl("btnSimple"));
       aspBtnUpdate = ((Button)row.FindControl("btnUpdate"));
       aspBtnCancel = ((Button)row.FindControl("btnCancel"));                   
   }
}

Here aspBtnEdit, btn, aspBtnUpdate, aspBtnUpdate are strings declared globally
Posted
Updated 10-Apr-18 2:17am

1 solution

Problem solved..... Previously i used timer interval to 100 and now i changed to 1000 working as expected.....
 
Share this answer
 

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