How to delete record from Datagrid and not from Database

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2006
Posts: 17
Reputation: Dhruv Shah is an unknown quantity at this point 
Solved Threads: 0
Dhruv Shah Dhruv Shah is offline Offline
Newbie Poster

How to delete record from Datagrid and not from Database

 
0
  #1
Nov 10th, 2006
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:
  1. <%@ Page Language="vb" AutoEventWireup="false" Codebehind="ShowJobs.aspx.vb" Inherits="COMPANY.ShowJobs"%>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  3. <HTML>
  4. <HEAD>
  5. <title>ShowJobs</title>
  6. <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
  7. <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
  8. <meta content="JavaScript" name="vs_defaultClientScript">
  9. <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  10. </HEAD>
  11. <body MS_POSITIONING="GridLayout">
  12. <form id="Form1" method="post" runat="server">
  13. <asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 336px; POSITION: absolute; TOP: 184px"
  14. runat="server" GridLines="both" AutoGenerateColumns="False" CellSpacing="3" CellPadding="3">
  15. <Columns>
  16. <asp:HyperLinkColumn NavigateUrl=".\UploadResume.aspx" DataTextField="JobHeading" HeaderText="Job Description"></asp:HyperLinkColumn>
  17. <asp:BoundColumn HeaderText="Area" DataField="JobArea"> </asp:BoundColumn>
  18. <asp:BoundColumn HeaderText="Location" DataField="Reqlocation"> </asp:BoundColumn>
  19. <asp:BoundColumn HeaderText="Experience" DataField="Experience"> </asp:BoundColumn>
  20. </Columns>
  21. </asp:datagrid></form>
  22. </body>
  23. </HTML>

  1. Imports System.Data
  2. Imports System.Data.SqlClient
  3. Public Class ShowJobs
  4. Inherits System.Web.UI.Page
  5.  
  6. #Region " Web Form Designer Generated Code "
  7.  
  8. 'This call is required by the Web Form Designer.
  9. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  10.  
  11. End Sub
  12. Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid
  13.  
  14. 'NOTE: The following placeholder declaration is required by the Web Form Designer.
  15. 'Do not delete or move it.
  16. Private designerPlaceholderDeclaration As System.Object
  17.  
  18. Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  19. 'CODEGEN: This method call is required by the Web Form Designer
  20. 'Do not modify it using the code editor.
  21. InitializeComponent()
  22. End Sub
  23.  
  24. #End Region
  25.  
  26. Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  27. 'Put user code to initialize the page here
  28. If Not IsPostBack Then
  29. Dim conn As SqlConnection
  30. Dim cmd As SqlDataAdapter
  31. Dim ds As New DataSet
  32. conn = New SqlConnection("Server=localhost;UID=sa;PWD=payal;database=onlinejob")
  33. cmd = New SqlDataAdapter("Select JobHeading,JobArea,Reqlocation,Experience from Recruitment_Mast,Recruitment_Trans where Recruitment_Mast.Recruitment_id = Recruitment_Trans.Recruitment_id", conn)
  34. cmd.Fill(ds, "Recruitment_Mast")
  35. DataGrid1.DataSource = ds.Tables("Recruitment_Mast").DefaultView
  36. DataGrid1.DataBind()
  37. End If
  38. End Sub
  39.  
  40. End Class
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 84
Reputation: web_developer is an unknown quantity at this point 
Solved Threads: 1
web_developer web_developer is offline Offline
Junior Poster in Training

Re: How to delete record from Datagrid and not from Database

 
0
  #2
Nov 14th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC