G
Guest
Hi,
I am using a compare validator in asp.net application(c# code). This is used
for comparing a value enterd by the user against the primary key in the SQL
database. IF the VALUE ENTERED BY THE USER EXISTS IN THE DB , then THE ERROR
MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle
"http://msdn.microsoft.com/library/d...ml/vbtskvalidatingagainstvaluesindatabase.asp" .
But it doesnt work. My code is::
private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEventArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();
// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}
I am using a compare validator in asp.net application(c# code). This is used
for comparing a value enterd by the user against the primary key in the SQL
database. IF the VALUE ENTERED BY THE USER EXISTS IN THE DB , then THE ERROR
MESSAGE OF THE COMPARE VALIDATOR SHOULD BE DISPLAYED.
For this, I used the reference artiicle
"http://msdn.microsoft.com/library/d...ml/vbtskvalidatingagainstvaluesindatabase.asp" .
But it doesnt work. My code is::
private void CustomValidator2_ServerValidate(object
source,System.Web.UI.WebControls.ServerValidateEventArgs args)
{
DataView dv= new DataView();
dv=dsValidate1.Tables[0].DefaultView;
string asi;
args.IsValid=true;
foreach(DataRowView datarow in dv)
{
// Extract asi from the current row
asi = datarow["Alias"].ToString();
// Compare asi against user's entry
if (asi == args.Value)
{
args.IsValid = false;
}
}
}