By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,131 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Client side scripting with asp datagrid

P: n/a
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


Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <xx@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

P: n/a
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" <mk*****@xx.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
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" <xx@nospam.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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


Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.