There is nothing tough stuff to validate Data Grid.
here is the code snippet which u can use to validate ur Data Grid.
protected void CarrierGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
lblErrorMessage.Visible = false;
System.Collections.Specialized.IOrderedDictionary disc;
disc = e.NewValues;
try
{
float value = float.Parse(disc["price"].ToString()); //checking float value if it is not , it will //give exception and control goes to the //catch block
}
catch (FormatException ex)
{
System.Console.Write(ex.Message);
e.Cancel = true; // I am canceling the updating event
lblErrorMessage.Visible = true;
}
catch (Exception ex)
{
System.Console.Write(ex.Message);
e.Cancel = true;
lblErrorMessage.Visible = true;
}
}
Thanks,
Jaydeep Vishwakarma
Thursday, February 14, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment