如何在c#中将datalist的复选框值添加到数组列表中 [英] How to add checked checkbox value of datalist to array list in c#

查看:162
本文介绍了如何在c#中将datalist的复选框值添加到数组列表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,任何人都可以帮我解决如何将已复选的复选框值添加到数组列表以及如何将此数组列表值发送到存储过程



提前谢谢

Hi all can any one help me out how to add checked checkbox value to array list and how to send this array list values to stored procedure

thank's in advance

推荐答案



你不能将像ArrayList这样的.NET集合传递给存储过程。所以,我建议你把字符串框架如下:

Hi,
you cannot pass a .NET collection like ArrayList into the stored Procedure. So, i suggest, you that frame the string something like below:
--  ID†Checked±ID†Checked±...
Ex: 1†true±2†false±3†true    -- true -> checked,  false -> unchecked 
    1†1±2†0±3†1              -- 1 -> checked,  0 -> unchecked



因此,将此字符串传递给过程并拆分相应的符号和相应的值。 ID表示复选框的任何标识,Checked表示选中或未选中复选框。



因此,您循环遍历datalist并构造字符串并传递给存储过程。



注:±(Alt + 0177)

†(Alt + 0134)





选项2:



i您使用的是SQL SERVER 2008或更高版本,您可以使用表值SQL参数。参考文章将数据表发送到存储过程 [< a href =http://www.codeproject.com/Articles/412802/Sending-a-DataTable-to-a-Stored-Proceduretarget =_ blanktitle =New Window> ^ ]用于将数据表发送到存储过程。



希望它有所帮助。


So, pass this string to the procedure and split on the respective symbols and the corresponding values. ID indicates any identification for the checkbox, "Checked" indicates checkbox checked or not.

So, you loop through the datalist and frame the string and pass to stored procedure.

Note: ± (Alt + 0177)
† (Alt + 0134)


Option 2:

i you are using SQL SERVER 2008 or later, you can use Table Valued SQL Parameters. refer the article Sending a DataTable to a Stored Procedure[^] for sending datatable to stored procedure.

hope it helps.


这篇关于如何在c#中将datalist的复选框值添加到数组列表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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