Hello Everybody,

I want to know that how we can delete the record from the datagrid only, that data should not be deleted from the database.
i.e., It should not be seen in webpage,but it should remain in the database.

Please help me out soon.My existing code is:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="ShowJobs.aspx.vb" Inherits="COMPANY.ShowJobs"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>ShowJobs</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 184px"
				runat="server" GridLines="both" AutoGenerateColumns="False" CellSpacing="3" CellPadding="3">
			<Columns>
				<asp:HyperLinkColumn NavigateUrl=".\UploadResume.aspx" DataTextField="JobHeading" HeaderText="Job Description"></asp:HyperLinkColumn>
				<asp:BoundColumn HeaderText="Area" DataField="JobArea"> </asp:BoundColumn>
				<asp:BoundColumn HeaderText="Location" DataField="Reqlocation"> </asp:BoundColumn>
				<asp:BoundColumn HeaderText="Experience" DataField="Experience"> </asp:BoundColumn>										
			</Columns>			
	</asp:datagrid></form>
	</body>
</HTML>
Imports System.Data
Imports System.Data.SqlClient
Public Class ShowJobs
    Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        If Not IsPostBack Then
            Dim conn As SqlConnection
            Dim cmd As SqlDataAdapter
            Dim ds As New DataSet
            conn = New SqlConnection("Server=localhost;UID=sa;PWD=payal;database=onlinejob")
            cmd = New SqlDataAdapter("Select JobHeading,JobArea,Reqlocation,Experience from Recruitment_Mast,Recruitment_Trans where Recruitment_Mast.Recruitment_id = Recruitment_Trans.Recruitment_id", conn)
            cmd.Fill(ds, "Recruitment_Mast")
            DataGrid1.DataSource = ds.Tables("Recruitment_Mast").DefaultView
            DataGrid1.DataBind()
        End If
    End Sub

End Class

man

i think to do that, you should after retrieving data from db, copy ur datasource to a session and then to datagrid.

then man if u want to delete from the datagrid only, you should delete from the session and rebind the datagrid to the session,

in this way, u didnt delete anything from db.

try it and tell us.

sam

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.