Validation for a datagrid column

Discussion in 'ASP .Net' started by steve.edison@gmail.com, Oct 18, 2005.

  1. Guest

    I have been trying to validate a textbox value, but unfortunately, the
    test for its validity is a function that must look up a value in a SQL
    database. The function returns true or false and that will determine
    the validity of the entry which is itself in a datagrid. Can anyone
    provide a sample of how this code would look? Sadly, I am terribly new
    to ASP.NET, so if you could also elaborate on whether any specific code
    must be in the ASP or the code-behind, I would appreciate it.
     
    , Oct 18, 2005
    #1
    1. Advertising

  2. I would suggest having a CustomValidator to do this. Add the custom validator
    control to the .aspx page and in the .aspx.cs or .vb file, capture the
    ServerValdiateEvent . In this event, write the code to connect to the
    database and verify the value entered.
    //Untested Pseudocode
    public void ServerValidation(object sender, ServerValidateeventArgs args)
    {
    if(ValidateAgainstDB(txtVal.Text))
    {
    args.IsValid=false;
    }

    }
    Here ValidateAgainstDB should verify the value against the database and
    should return a true if the value is valid and false for Invalid
    --
    Aarthi R S



    "" wrote:

    > I have been trying to validate a textbox value, but unfortunately, the
    > test for its validity is a function that must look up a value in a SQL
    > database. The function returns true or false and that will determine
    > the validity of the entry which is itself in a datagrid. Can anyone
    > provide a sample of how this code would look? Sadly, I am terribly new
    > to ASP.NET, so if you could also elaborate on whether any specific code
    > must be in the ASP or the code-behind, I would appreciate it.
    >
    >
     
    =?Utf-8?B?QWFydGhp?=, Oct 18, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Hammond
    Replies:
    1
    Views:
    3,624
    bruce barker
    Nov 26, 2003
  2. Hai Nguyen
    Replies:
    0
    Views:
    404
    Hai Nguyen
    Jan 16, 2004
  3. Dexter
    Replies:
    1
    Views:
    419
    Eliyahu Goldin
    Jan 18, 2005
  4. John E.
    Replies:
    3
    Views:
    4,471
    masoud bayan
    Mar 25, 2005
  5. =?Utf-8?B?V2FyYW4=?=

    HyperLink Column and Button Column in a DataGrid

    =?Utf-8?B?V2FyYW4=?=, Aug 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    604
    =?Utf-8?B?V2FyYW4=?=
    Aug 9, 2005
Loading...

Share This Page