Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Remove GridView row on click?
Posted
Comments
Karthik_Mahalingam 30-Nov-13 1:20am    
Please add more info to your question..

it should happen on client side or server side ???

Please post some code...
[no name] 30-Nov-13 1:27am    
Client side
Karthik_Mahalingam 30-Nov-13 1:41am    
check my sample

Hello ,

There are lots of solutions available in google .

try these

Simple-Insert-Select-Edit-Update-and-Delete-in-ASPNet-GridView-control

another one

how-to-inserteditupdate-and-delete-data-in gridview

thanks
 
Share this answer
 
If you are using GridView, On the Client Side it will render as HTML table only..

so using jquery u can remove the table row in client side..

please go through the following links to see how to remove in client side..



http://stackoverflow.com/questions/170997/what-is-the-best-way-to-remove-a-table-row-with-jquery[^]

http://stackoverflow.com/questions/370013/jquery-delete-all-table-rows-except-first[^]

http://stackoverflow.com/questions/16200104/jquery-add-and-remove-table-rows[^]


try this sample code...



XML
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="POC.WebForm2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script src="jquery-1.10.2.min.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(function () {

            $("#gv tr").click(function () {
                $(this).remove();
            });
        });


    </script>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:GridView ID="gv" runat="server">
    </asp:GridView>
    </form>
</body>
</html>







C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace POC
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack) { }
            else
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("id", typeof(int));
                dt.Columns.Add("value", typeof(string));
                for (int i = 0; i < 20; i++)
                    dt.Rows.Add(i, "value---" + i);

                gv.DataSource = dt;
                gv.DataBind();
            }
        }
    }
}
 
Share this answer
 
Read this
 
Share this answer
 
v2

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