473,379 Members | 1,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Delete button code using checkbox

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.SqlClient;
  10.  
  11. namespace Iselibrary
  12. {
  13. public partial class Delete : Form
  14. {
  15. SqlConnection vid = new SqlConnection("Data Source=.;Initial Catalog=iselibrary;Integrated Security=True");
  16. //private object item;
  17.  
  18. public Delete()
  19. {
  20. InitializeComponent();
  21. }
  22. private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
  23. {
  24.  
  25. }
  26.  
  27. private void button1_Click_1(object sender, EventArgs e)
  28. {
  29. this.Close();
  30. Home home = new Home();
  31. home.Show();
  32. }
  33.  
  34. private void Update_Load(object sender, EventArgs e)
  35. {
  36. // TODO: This line of code loads data into the 'iselibraryDataSet1.T_BOOK_ISSUE_TABLE' table. You can move, or remove it, as needed.
  37. this.t_BOOK_ISSUE_TABLETableAdapter.Fill(this.iselibraryDataSet1.T_BOOK_ISSUE_TABLE);
  38.  
  39. }
  40.  
  41. private void button2_Click(object sender, EventArgs e)
  42. {
  43. String str = "Select * from T_BOOK_ISSUE_TABLE where (USN like '%' + @search + '%')";
  44. SqlCommand xp = new SqlCommand(str, vid);
  45. xp.Parameters.Add("@search", SqlDbType.NVarChar).Value = textBox1.Text;
  46.  
  47.  
  48. vid.Open();
  49. xp.ExecuteNonQuery();
  50. SqlDataAdapter da = new SqlDataAdapter();
  51. da.SelectCommand = xp;
  52. DataSet dat = new DataSet();
  53. da.Fill(dat, "USN");
  54. dataGridView1.DataSource = dat;
  55. dataGridView1.DataSource = dat.Tables[0];
  56. vid.Close();
  57. }
  58.  
  59. private void textBox1_TextChanged(object sender, EventArgs e)
  60. {
  61.  
  62. }
  63. // Delete Button Details//
  64. private void button3_Click(object sender, EventArgs e)
  65. {
  66. iselibraryEntities ise = new iselibraryEntities();
  67. foreach (var item in dataGridView1.Rows)
  68. {
  69. DataGridViewRow row = item as DataGridViewRow;
  70. if (row.Selected)
  71. {
  72. string usn = row.Cells["USN"].Value.ToString();
  73. var issu = ise.T_BOOK_ISSUE_TABLE.FirstOrDefault(a => a.USN.Equals(usn));
  74. if (issu != null)
  75. {
  76. ise.T_BOOK_ISSUE_TABLE.Remove  /* as error occurs here I have not completed the code*/
  77. }
  78. }
  79. }
  80. }
  81.  
  82. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  83. {
  84.  
  85. }
  86. }
  87. }
  88.  
As soon as i complete ise.T_BOOK_ISSUE_TABLE. in If loop, I dont get a dropdown for Remove. Why so? and error says as:'Object Query<T_BOOK_ISSUE_TABLE>' does not contain a definition for 'remove' and no extension method 'remove' accepting a first argument of type'Object Query<T_BOOK_ISSUE_TABLE>'could be found(are you missing a directive or an assembly reference?)
Please let me know where im going wrong or anyone out there please help me to write delete button code using checkbox checked. Hope anyone in forum helps....
Thank you
Oct 22 '15 #1
0 1408

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Niranjan | last post by:
Windows 2000 Access 2000 I have the standard Delete button code. This has been working for over 3-4 years and now it gives me an error message of 2465 everytime I delete a record. Here is...
4
by: Elliot M. Rodriguez | last post by:
I have a Delete button in my datagrid. I'm attempting to add some code confirming whether the user wishes to really delete the item or not. The confirm pops up, but I cannot suppress the...
3
by: vcornjamb | last post by:
Hello, I am developing a web form that contains some buttons and a data grid which has as its last column link buttons that will delete the data associated with that row. Everything works fine,...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
3
madhoriya22
by: madhoriya22 | last post by:
I have solved the problem
7
by: mukeshrasm | last post by:
hello everyone I want to delete the selected records from database using checkbox. whch is generated dyanamically and checkbox is also generated dynamically,using php. so please help me. if you...
13
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. ...
1
by: puneetmca | last post by:
hi...this code of deleting a record from database using checkbox is not working...echo "<td>$row</td>; echo "<td>$row</td>"; echo "<td>$row....these lines print as it is...rather then...
4
by: shinypenny | last post by:
Hello all, I am trying to use PHP to pull information from a mySQL database, as well as offer an "Add More" button through the use of JavaScript. I'm able to put the new information into the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.