Client side scripting with asp datagrid

P

Paul

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
 
K

Kannan Meiappan

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
 
P

Paul

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 said:
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 said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top