Client side event for datagrid control

Discussion in 'ASP .Net Datagrid Control' started by Xavier Pacheco, Jul 28, 2005.

  1. This is probably a simple one, but I cannot seem to find an example.

    I have a datagrid with each row containing

    Checkbox | Textbox | Validation

    When the checkbox column is checked for a given row, TextBox is
    enabled, initialized with a value and the validation is enabled.

    When the checkbox column is unchecked, Textbox is disabled, initialized
    to Emtpy and validation is disabled.

    Any pointers?
    - xavier
     
    Xavier Pacheco, Jul 28, 2005
    #1
    1. Advertising

  2. Xavier Pacheco

    Lamont Guest

    In your datagrids ItemDataBound event you have to do something like this...

    szCheckScript &= "document.frmCC.dgContracts__ctl" & _
    e.Item.ItemIndex + 2 & "_" & e.Item.Cells(7).Controls(7).ID & _
    ".disabled=false;"
    szUnCheckScript &= "document.frmCC.dgContracts__ctl" & _
    e.Item.ItemIndex + 2 & "_" & e.Item.Cells(7).Controls(7).ID & _
    ".disabled=true;"

    tmpChkBox = CType(e.Item.Cells(2).Controls(1), CheckBox)
    tmpChkBox.Attributes.Add("onclick", "if (this.checked) {" & _
    szCheckScript & _
    "} else {" & _
    szUnCheckScript & _
    "}")

    View the source on your page when you run it and look at the names .NET
    assigns to the checkbox controls in the datagrid. That will explain all the
    ctl code where it is getting the name of the control.

    Hope that makes sense.
    --
    Lamont - OKC Developer


    "Xavier Pacheco" wrote:

    > This is probably a simple one, but I cannot seem to find an example.
    >
    > I have a datagrid with each row containing
    >
    > Checkbox | Textbox | Validation
    >
    > When the checkbox column is checked for a given row, TextBox is
    > enabled, initialized with a value and the validation is enabled.
    >
    > When the checkbox column is unchecked, Textbox is disabled, initialized
    > to Emtpy and validation is disabled.
    >
    > Any pointers?
    > - xavier
    >
     
    Lamont, Jul 29, 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. =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
    Replies:
    2
    Views:
    6,496
    rick74
    May 27, 2008
  2. Boss302
    Replies:
    0
    Views:
    1,056
    Boss302
    Nov 21, 2006
  3. Bogdan
    Replies:
    2
    Views:
    655
    Bogdan
    Jun 9, 2008
  4. Zoe Hart
    Replies:
    1
    Views:
    373
    Scott Wisniewski
    Jan 8, 2004
  5. Guest

    Fire server side event before client side event

    Guest, Mar 17, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    597
    Ken Cox [Microsoft MVP]
    Mar 18, 2005
Loading...

Share This Page