edit row values and populate them on modal popup

Aug 2 2017 8:56 AM

My requirement : I am creating a web application (ASP.NET), and I added S.NO. , Edit and Delete columns through Item Template in my existing Employee table. I created a modal popup to be generated when I click on edit button in grid row based on the row index, I took input field for edit and delete buttons instead of asp controller button because with asp controller I can't open modal pop up properly. can anybody help me with code-behind to get the row values and populate them in modal Popup .

My Html code for gridview


<asp:GridView ID="gvSearchData" runat="server" DataKeyNames="ID" class="table table-hover table-striped table-condensed" > <Columns> <asp:TemplateField HeaderText="S.No"> <ItemTemplate> <%#Container.DataItemIndex+1 %> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Edit"> <ItemTemplate> <input id="btnEdit" type="button" commandname="Edit" runat="server" value="Edit" class="btn btn-info btn-sm" data-toggle="modal" data-target="#myEditModal" commandargument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' /> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Delete"> <ItemTemplate> <input id="btnDelete" type="button" commandname="Delete" runat="server" value="Delete" class="btn btn-danger btn-sm" data- toggle="modal" data-target="#myDeleteModal" commandargument='<%# DataBinder.Eval(Container.DataItem, "ID") %>' /> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>


 


Answers (2)