How do I check duplicate field in the DataGridView

T

Tony Johansson

Hello!

I have a DataGridView with 6 columns one of these is a social security
number that is unique to every person and
the primary key for the database table.

Now when I enter this social security number I want to check that it doesn't
exist in DataGridView because I want to avoid getting error from the
database when I save to the database.

What is the best way to do that ?

//Tony
 
O

Osamede.Zhang

Hello!

I have a DataGridView with 6 columns one of these is a  social security
number that is unique to every person and
the primary key for the database table.

Now when I enter this social security number I want to check that it doesn't
exist in DataGridView because I want to avoid getting error from the
database when I save to the database.

What is the best way to do that ?

//Tony
you can add a css class to social security number textbox,for
example:
<EditItemTemplate>
<asp:TextBox runat="server"
CssClass="socialsecuritynumber"></asp:TextBox>
</EditItemTemplate>

then add a javascript keyup event handler to every html input whose
css name is "socialsecuritynumber", like this:
$(".socialsecuritynumber").keyup(function(){
//check security number doesn't exist
}
};

sorry for my poor english

---Osamede Zhang
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top