从ArrayList获取值 [英] To get the values from ArrayList

查看:98
本文介绍了从ArrayList获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家..

i编写代码,在表格中动态添加多个单选按钮。每个单元格有4-5个单选按钮,每行有几个不同组名称的单选按钮。我可以在arraylist中添加每个单选按钮ID。我的问题如何在arraylist中获取已检查的单选按钮ID。







请帮助我< br $>




提前谢谢你

Hi experts..
i write the code for to add multiple radio buttons dynamically in table.. each cell have 4-5 radio buttons and each row have several radio buttons with different group name.. each radio button id i can add in arraylist. my problem how to get the checked radio buttons ids in arraylist..



please help me


Thank You in advance

推荐答案

如果你最终想得到服务器上ArrayList中所选单选按钮的id'。我认为你可以用很少的javascript来完成这个。



说,你有一个表很多单选按钮。还有一个提交表单的提交按钮。



请按照以下步骤操作:



1)制作一个javascript收集所选单选按钮的ID并将其添加到由唯一字符分隔的字符串中的函数,并将其命名为COLLECTOR FUNCTION。比如,用户选择板球,网球和篮球单选按钮,然后该功能应返回c#t#b,其中#是唯一的字符,c,t,b是它们各自的ID。



2)当用户点击提交按钮时,在其事件处理函数中调用收集器函数

并使用收集器函数的输出向服务器发出ajax get请求作为查询字符串。

例如。请求arrylist.aspx?q = c#t#b



3)在服务器端获取该查询字符串,并通过字符串''拆分ids拆分功能

并将它们存储到数组列表中。



最好的运气.. :)
If you finally want to get the id''s of the selected radio-buttons in the ArrayList at server.I think you can do this with little javascript.

Say, you have a table with lots of radio buttons. And a submit button for submitting the form.

Follow these steps:

1)Make a javascript function which collects the ids of selected radio buttons and add them up in a string separated by unique character, and name it COLLECTOR FUNCTION. Say, the user selects cricket, tennis and basket ball radio buttons then the function should return "c#t#b" where # is the unique character and c,t,b are their respective ids.

2)When the user clicks on the submit button, in its event handler function call collector function
and make an ajax get request to the server with the output of collector function as query string.
eg. make request "arrylist.aspx?q=c#t#b"

3)Get that query string at server side, and split the ids through string''s split function
and store them to array list.

Best of Luck.. :)


而不是 ArrayList ,使用 System.Collections.Generic.List<> http://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110 %29.aspx [ ^ ]。



非通用非专业馆藏,如 ArrayList 早在.NET Framework v.2.0中,当引入泛型时,它们是绝对的,因此它们永远不应该用于新开发。没有标记 [Obsolete] 属性,因为将它们保存在已经开发和调试的遗留代码中没有任何问题,但是类型转换中可能不安全的需要使得不适合。



-SA
Instead of ArrayList, use System.Collections.Generic.List<>: http://msdn.microsoft.com/en-us/library/6sh2ey19%28v=vs.110%29.aspx[^].

Non-generic non-specialized collections like ArrayList was rendered absolute as early as of .NET Framework v.2.0, when generics were introduced, so they should never be used in new development. The were not marked with [Obsolete] attribute just because there is nothing wrong with keeping them in already developed and debugged legacy code, but the potentially unsafe need in type cast makes then unsuitable.

—SA


这篇关于从ArrayList获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆