Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem with asp.net gridview
    text
    copied!<p>I have problem with gridview deleting.I have table name Doctor with Id,Name,Address,Phone.Id is auto generated field.After adding data when i am displaying in gridview then if delete any id from gridview Again then if i add any new details from the form its starting from the new number.I mean if i delete the last id no 5 then again if i add any new doctor its taking id value 6 not from 5.My query is it should start again from 5.Here is my code.Pls help me.</p> <pre><code>public class Doctor { public int Id { get; set; } public string Name { get; set; } public string Address { get; set; } public string Phone { get; set; } } public static class DoctorDataLayer { public static void AddDoctor(Doctor doctor) { string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; // JohannesH: Changed from .ToString() to .ConnectionString using(var connection = new SqlConnection(connectionString)) { using (var command = new SqlCommand("insert into doctor values(@name,@address,@phone)", connection)) { command.Parameters.AddWithValue("@name", doctor.Name); command.Parameters.AddWithValue("@address", doctor.Address); command.Parameters.AddWithValue("@phone", doctor.Phone); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } } } } public static class DoctorBusinessLayer { public static void CreateDoctor(string name, string address, string phone) { DoctorDataLayer.AddDoctor(new Doctor {Name = name, Address = address, Phone = phone}); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload