Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am new to asp.net. i have a gridview with edit button.
when i click that button first time nothing happens. but next time previous row get selected. please help me out.




thanks
Posted
Updated 16-Jan-12 21:50pm
v2
Comments
RDBurmon 17-Jan-12 3:44am    
Please post your code .
Tejas Vaishnav 17-Jan-12 3:54am    
provide your design code of gridview
Manoj Kumar Choubey 17-Jan-12 3:57am    
Please post your code , (and check selected index)

I encountered the same issue .The problem is with your datatbind logic.

Please check your code for these issues:

1. The grid databind logic must be in Page_Load event.

2. It should be enclosed inside if(!Page.IsPostBack) { //databind logic here; }
 
Share this answer
 
use this

XML
<Columns>
                                                    <asp:TemplateField ItemStyle-Width="90px">
                                                        <EditItemTemplate>
                                                            <asp:ImageButton ID="imgbtnUpdate" CommandName="Update" runat="server" ImageUrl="~/Images/update.png"
                                                                ToolTip="Update" />
                                                            <asp:ImageButton ID="imgbtnCancel" runat="server" CommandName="Cancel" ImageUrl="~/Images/Cancel.png"
                                                                ToolTip="Cancel" />
                                                        </EditItemTemplate>
                                                        <ItemTemplate>
                                                            <asp:ImageButton ID="imgbtnEdit" CommandName="Edit" runat="server" ImageUrl="~/Images/Edit.png"
                                                                ToolTip="Edit" />
                                                            <asp:ImageButton ID="imgbtnDelete" CommandName="Delete" Text="Edit" runat="server"
                                                                ImageUrl="~/Images/delete.png" ToolTip="Delete" Height="20px" Width="20px" />
                                                        </ItemTemplate>
                                                        <FooterTemplate>
                                                            <asp:ImageButton ID="imgbtnAdd" runat="server" ImageUrl="~/Images/AddNewitem.png"
                                                                CommandName="AddNew" />
                                                        </FooterTemplate>
                                                    </asp:TemplateField>
 
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