Client side scripting with asp datagrid

Discussion in 'ASP .Net' started by Paul, Oct 12, 2004.

  1. Paul

    Paul Guest

    If it's possible I would like to perform some client side actions on my
    Visual Basic asp.net application. An example of what I'm trying to do.

    I have a DATAGRID with columns ITEM, ITEMTYPE and a template column with a
    checkbox in it called "MATCH"
    Example

    ITEM ITEMTYPE MATCH
    Banana Fruit [ ]
    Vegatable [ ]
    Mineral [ ]
    Sprouts Fruit [ ]
    Vegatable [ ]
    Mineral [ ]

    If for example the user clicks the Fruit checkbox against the Banana, then
    ideally I would like disable the checkbox against Vegatable and Mineral
    within the banana grouping, because I do not want the user to select
    multiples within the ITEM grouping.

    Is this possible with I guess client side scripting? I have not done much
    client side so any hints would be appreciated.

    Thanks
    Paul
     
    Paul, Oct 12, 2004
    #1
    1. Advertising

  2. Hi Paul,

    you can do something like this...


    <asp:TemplateColumn>
    <ItemStyle HorizontalAlign="Center"
    Width="25px"></ItemStyle>
    <ItemTemplate>
    <input type="checkbox" id="chkItem" name="chkItem"
    runat="server" value='<%#DataBinder.Eval(Container.DataItem, "FruitId") %>'
    onclick="<javascript:functionfruit(this)>">
    </ItemTemplate>
    </asp:TemplateColumn>

    Have some naming convention for your checkbox(eg: join the main and sub
    category with underscore). In the javascript function pass this as
    parameter. Somthing like below,

    <script>
    function functionfruit(obj)
    {
    alert(obj.id);
    }
    </script>

    you will be having control on which checkbox you checked. based on which
    you can handle your scenario.

    Regards,
    Kannan

    "Paul" <> wrote in message
    news:%...
    > If it's possible I would like to perform some client side actions on my
    > Visual Basic asp.net application. An example of what I'm trying to do.
    >
    > I have a DATAGRID with columns ITEM, ITEMTYPE and a template column with a
    > checkbox in it called "MATCH"
    > Example
    >
    > ITEM ITEMTYPE MATCH
    > Banana Fruit [ ]
    > Vegatable [ ]
    > Mineral [ ]
    > Sprouts Fruit [ ]
    > Vegatable [ ]
    > Mineral [ ]
    >
    > If for example the user clicks the Fruit checkbox against the Banana, then
    > ideally I would like disable the checkbox against Vegatable and Mineral
    > within the banana grouping, because I do not want the user to select
    > multiples within the ITEM grouping.
    >
    > Is this possible with I guess client side scripting? I have not done much
    > client side so any hints would be appreciated.
    >
    > Thanks
    > Paul
    >
    >
    >
    >
     
    Kannan Meiappan, Oct 12, 2004
    #2
    1. Advertising

  3. Paul

    Paul Guest

    OK Thanks Kannan that gets me started, but I actually want to manipulate
    other checkboxes in different rows of the datatable, not really the one I am
    currently on. So how do I reference a checkbox on another row. In asp I
    would use something like

    dim cb as checkbox
    checkbox = datagrid1.items(1).findcontrol("CHECKBOX")

    How can I do that in javascript?

    hanks

    "Kannan Meiappan" <> wrote in message
    news:%...
    > Hi Paul,
    >
    > you can do something like this...
    >
    >
    > <asp:TemplateColumn>
    > <ItemStyle HorizontalAlign="Center"
    > Width="25px"></ItemStyle>
    > <ItemTemplate>
    > <input type="checkbox" id="chkItem"

    name="chkItem"
    > runat="server" value='<%#DataBinder.Eval(Container.DataItem, "FruitId")

    %>'
    > onclick="<javascript:functionfruit(this)>">
    > </ItemTemplate>
    > </asp:TemplateColumn>
    >
    > Have some naming convention for your checkbox(eg: join the main and sub
    > category with underscore). In the javascript function pass this as
    > parameter. Somthing like below,
    >
    > <script>
    > function functionfruit(obj)
    > {
    > alert(obj.id);
    > }
    > </script>
    >
    > you will be having control on which checkbox you checked. based on which
    > you can handle your scenario.
    >
    > Regards,
    > Kannan
    >
    > "Paul" <> wrote in message
    > news:%...
    > > If it's possible I would like to perform some client side actions on my
    > > Visual Basic asp.net application. An example of what I'm trying to do.
    > >
    > > I have a DATAGRID with columns ITEM, ITEMTYPE and a template column with

    a
    > > checkbox in it called "MATCH"
    > > Example
    > >
    > > ITEM ITEMTYPE MATCH
    > > Banana Fruit [ ]
    > > Vegatable [ ]
    > > Mineral [ ]
    > > Sprouts Fruit [ ]
    > > Vegatable [ ]
    > > Mineral [ ]
    > >
    > > If for example the user clicks the Fruit checkbox against the Banana,

    then
    > > ideally I would like disable the checkbox against Vegatable and Mineral
    > > within the banana grouping, because I do not want the user to select
    > > multiples within the ITEM grouping.
    > >
    > > Is this possible with I guess client side scripting? I have not done

    much
    > > client side so any hints would be appreciated.
    > >
    > > Thanks
    > > Paul
    > >
    > >
    > >
    > >

    >
    >
     
    Paul, Oct 12, 2004
    #3
    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. e
    Replies:
    2
    Views:
    414
    Charlie@CBFC
    Nov 21, 2003
  2. Brian W
    Replies:
    4
    Views:
    3,745
    Brian W
    Mar 4, 2004
  3. Rob
    Replies:
    7
    Views:
    6,170
    Patrick.O.Ige
    Dec 7, 2005
  4. Boss302
    Replies:
    0
    Views:
    1,056
    Boss302
    Nov 21, 2006
  5. Kathryn
    Replies:
    9
    Views:
    210
    William Morris
    Oct 17, 2003
Loading...

Share This Page