我们如何在数据库的表中保存多个复选框的数据? [英] How we can save data in table in database for multiple checkboxes?

查看:171
本文介绍了我们如何在数据库的表中保存多个复选框的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在pl/sql中将数据库中的多个复选框保存在表中的数据.

How we can save data in table in database for multiple checkboxes in pl/sql.

推荐答案

您可以用逗号分隔的形式保存复选框的值.

You can save checkboxes value with comma separate.

string SelectedValue = string.Empty,blankValue=string.Empty;
                foreach (ListItem item in chklist.Items)
                {
                    if (item.Selected)
                    {
                        SelectedValue += item.Value + ",";
                    }
                    else
                    {
                        blankValue += item.Value + ",";
                    }
                }



请注意,此代码用于CheckBoxList,而不用于CheckBox.

正如您提到的多个复选框一样,我已经提供了此解决方案.因此,我认为复选框是相关的项目.


您需要执行一些步骤以将selectedValue变量的值保存到SQL数据库.
1.创建一个具有适当字段名称和数据类型的表
2.为varchar类型的checkboxIds添加一列
3.使用插入查询创建一个存储过程,该存储过程将传递的selectedvalue参数保存在表中
4.在您的应用程序中创建一个函数,该函数将接受参数并将其传递给存储过程
5.调用此函数并传递变量SelectedValue

NOTE : In the question you have write PL/SQL and you have tag it for Oracle. So I have changed it to the SQL.



Please note that this code is for CheckBoxList and not for CheckBox.

I have provided this solution as you have mentioned multiple checkboxes. So I assume that checkboxes are related items.


You need to follow some steps to save the value of selectedValue variable to SQL database.
1. Create a table with appropriate fields name and data type
2. Add a column for checkboxIds of varchar type
3. Create a store procedure with insert query which save the passed selectedvalue parameter in table
4. Create a function in your application, which will accept the parameter and passed it to the store procedure
5. Call this function and pass the variable SelectedValue

NOTE : In the question you have write PL/SQL and you have tag it for Oracle. So I have changed it to the SQL.


这篇关于我们如何在数据库的表中保存多个复选框的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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