Gridview How to catch unique constraint value error in a control
<p>I have a gridview and sqldatasource to bind data from datatable to the gridview .</p>

<p>When I'm updating a value from a cell with a new one , and the value already exists in other cell of the gridview , I will get contraint error for unique value in a new page and it looks really bad for user.</p>

<p>How can I catch that error and display in a label another text to warn the user the value already exists? </p>

<p>So , I'm not adding something to gridview from an event and there's nothing I can catch. 
I need to make a general rule or something and I don't know how.</p>

<p>I've tried this but it didn't worked , is not showing up .</p>

<pre><code>protected void GridViewUpdateEventHandler(Object sender, GridViewUpdatedEventArgs e)
{
    if(e.Exception!=null)
    {
       lblForError.Text="Value already exists"; //etc
    }
}
</code></pre>

<p>Thanks</p>
