am using a grid view in my application. and putting the data directly from the other text box control. i am not using any database. it keeps on adding the data one after another in next rows if the data changes.

now, i want to delete a row from the grid view only and not from any databases.

can anyone help me on this????

i am setting auto generatedeletebuton property to true. so that i can use these to delete a row.

but i don't know wt to write in row deleting event in this case. help!!!!!!!!!!!!!!!!!!!!

OR i can use the radio buttons, and based on selection i can delete the selected row.

Did you use DataTable to save data and display data in Gridview ?
I hope our case is same....

Let's me try to help you :

<asp:GridView ID="GVDetail" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" AutoUpdateAfterCallBack="True" BackColor="LightGray"
          BorderColor="White" BorderStyle="Ridge" BorderWidth="1px" CaptionAlign="Top" CellPadding="0" Font-Size="12px" Font-Strikeout="False" Font-Underline="False" Height="1px" HorizontalAlign="Left" Style="left: 4px; top: 127px" UpdateAfterCallBack="True" Width="100%"  EmptyDataText="NO RECORD FOUND" PageSize="12">
                    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                    <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" Font-Italic="False" Font-Underline="False"
                        ForeColor="#E7E7FF" />
                    <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                    <Columns>
                     <asp:templatefield headertext="Del."  >
                            <itemstyle borderstyle="None" font-size="8pt" width="10px" horizontalalign="Center" />
                            <headerstyle font-bold="False" width="10px" font-size="8pt"/>
                            <itemtemplate>
                                <asp:CheckBox id="ChkDelete" runat="server" width="20px" ></asp:CheckBox>                                                                                               
                        </itemtemplate>
                        </asp:templatefield>                         
                         <asp:templatefield headertext="Article No.">
                            <itemstyle borderstyle="None" font-size="8pt" width="20px" />
                            <headerstyle font-bold="False" width="65px" font-size="8pt"/>
                            <itemtemplate>
                                <asp:TextBox id="TxtArticleNo" readonly=true text='<% # eval("ArticleNo") %>' runat="server" width="65px" borderstyle="None" font-size="8pt" BackColor="LightCyan"></asp:TextBox>                                                                                                              
		</itemtemplate>
                        </asp:templatefield>                         
                        <asp:templatefield headertext="Amount">
                            <itemstyle borderstyle="None" font-size="8pt" width="20px" />
                            <headerstyle font-bold="False" width="65px" font-size="8pt"/>
                            <itemtemplate>
                                <asp:TextBox id="Amount" text='<% # eval("AMOUNT") %>' runat="server" width="65px" borderstyle="None" font-size="8pt"   BackColor="Beige"></asp:TextBox>                                                                                 
                        </itemtemplate>
                        </asp:templatefield>                            
                    </Columns>
                    <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
             <AlternatingRowStyle BackColor="LightGray" />
                </asp:GridView>
Dim Row As GridViewRow
        Dim DT As New DataTable
        DT = ViewState("ArticleTable")
        For Each Row In GVDetail.Rows
            Dim cbDelete As CheckBox = CType(Row.FindControl("ChkDelete"), CheckBox)
            If cbDelete.Checked = True Then
                Dim TxtArticleNo As New TextBox
                TxtArticleNo = Row.FindControl("TxtArticleNo")
                Dim DelRow As DataRow
                DelRow = DT.Rows.Find(TxtArticleNo.Text.Trim)
                If Not DelRow Is Nothing Then DT.Rows.Remove(DelRow)
            End If
        Next
        DT.AcceptChanges()
        GVDetail.DataSource = DT
        GVDetail.DataBind()
        ViewState("ArticleTable") = DT
        CalculateAmount()
This article has been dead for over six months. Start a new discussion instead.