User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 427,460 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,595 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3600 | Replies: 1
Reply
Join Date: Sep 2006
Posts: 17
Reputation: Dhruv Shah is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Dhruv Shah Dhruv Shah is offline Offline
Newbie Poster

Help How to delete record from Datagrid and not from Database

  #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
  41.  
  42.  
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2006
Posts: 84
Reputation: web_developer is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
web_developer web_developer is offline Offline
Junior Poster in Training

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

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC