Hibernate version: 1.0.2
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using: SQL Server 2005
Hello,
I'm new to NHibernate and I need some help.
In my ASP.NET Web Form, I've got a gridVeiw bound to a database through NHibernate.
I implemented Adding, Inserting, Updating and Deleting methods.
Actually, my problem is that when I delete an Item from my gridView, it is temporarily deleted because when I try to delete another item, the item previosly deleted reappears.
Please really need some help, does the problem come from NHibernate configuration of from my gridview.
Code:
public void Delete(Collabs c, int id)
{
ISession session = sessionFactory.OpenSession();
ITransaction tx = session.BeginTransaction();
try
{
session.Delete("from Collabs c where c.Id = :Id", id, NHibernate.NHibernateUtil.Int32);
tx.Commit();
}
catch
{
tx.Rollback();
}
finally
{
session.Close();
}
}
Code:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
GridViewRow row = GridView1.Rows[e.RowIndex];
object id = this.GridView1.DataKeys[e.RowIndex].Value;
Collabs col = new Collabs();
if (id != null)
{
col.Id = Convert.ToInt32(id);
agence.Delete(col, col.Id);
GridView1.DataSource = agence.PrintAll();
Bindings();
}
}
Regards