How to edit a asp.net gridview row.

I need to know how to edit a asp.net gridview row when it has been uploaded from an excel spreadsheet but has not been saved to a SQL database. I want to give the option to the user to edit and delete rows in the gridview table after they have uploaded the table from excel file before they submit the gridview to the SQL database.
Please help.
Thank you,
newjeep19Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

zephyr_hex (Megan)DeveloperCommented:
For each of your ItemTemplate tags in the gridview, add an EdittItemTemplate tag.  And then add a column with the edit and delete buttons.  For example:

<ItemTemplate>
     <tr>
        <td><%# Eval("FirstName") %></td>
     </tr>
</ItemTemplate>
 <EditItemTemplate>
      <tr>
        <td><asp:TextBox runat="server" ID="txtFirstName" CssClass="text" style="width:76px;" MaxLength="50" Text='<%# Eval("FirstName") %>'/></td>
     </tr>
</EditItemTemplate>
<asp:CommandField ButtonType="Link" ShowEditButton="true" ShowDeleteButton="true" ItemStyle-Width="150"/>

Open in new window

newjeep19Author Commented:
My asp.net gridview is dynamic see the code below:
<asp:GridView ID="gvNew" runat="server"
                                OnSelectedIndexChanged="gvNew_SelectedIndexChanged"
                                OnRowEditing="EditCustomer"
                                OnRowUpdating="UpdateScoreCard"
                                OnRowCommand="gvGetExsistingPromo_RowCommand"
                                ShowFooter="true"
                                OnRowCancelingEdit="CancelEdit">
                                <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                                <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                                <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                                <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" Height="75px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                <AlternatingRowStyle BackColor="#F7F7F7" />
                                <Columns>
                                    <%--<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
                                    <asp:BoundField DataField="Country" HeaderText="Country" ItemStyle-Width="150" />--%>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnedit" runat="server" CommandName="Edit" ImageUrl="~/images/Edit.png" Width="50px" Visible="true" CommandArgument="<%# Container.DataItemIndex %>" />
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                                                                       <asp:ImageButton ID="imgAddBtn" runat="server" Width="50px" ImageUrl="~/images/addfixed.png" OnClientClick="imgAddBtn_Click" />
                                                                                   </EditItemTemplate>
                                    </asp:TemplateField>
                                    <%--<Delete Button>--%>
                                    <asp:TemplateField>
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgDeleteBtn" runat="server" Width="50px" ImageUrl="~/images/Delete.png" OnClientClick="return confirm('Do you want to delete?')" CausesValidation="False" CommandName="Delete" Visible="true" ToolTip="Send an email to the course attendees"></asp:ImageButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>

Open in new window

newjeep19Author Commented:
Any thoughts on this? Please help!
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

Jitendra PatilSr.Software EngineerCommented:
you can try providing  a popup  for editing row values, showing the selected row for edit on edit click,
on the row command event  get the id of the row Or the record, get the latest changes provided by the user and update the same in datatable or dataset and again rebind the grid.

hope this helps.
newjeep19Author Commented:
I found a way to edit the gridview by using asp.net place holder

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newjeep19Author Commented:
I found a way using asp.net place holder.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.