如何在使用Loop时将所有选中的复选框列表值插入数据库? [英] How to insert all selected checked box list values to the database while using Loop?

查看:62
本文介绍了如何在使用Loop时将所有选中的复选框列表值插入数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有学生管理系统我想为一个学生选择多个科目,使用复选框列表控件插入数据库.... plz快速解决代码...

I have student management system i want to select multiple subjects for one student to insert in database using checked box list control.... plz give quick solution with code...

推荐答案

只需使用looop,它将检查在for side循环中写入插入代码后单击复选框列表中的复选框数

just use for looop that will check how many checkbox in a checkbox list are clicked after that write your insert code in side for loop
for(int i=0;i<checkboxlist1.items.count,i++)>
{
//your insertion code goes hear
}


参考:

CheckBoxList-选择并重新填充-CheckBoxList-from-saved-data [ ^ ]


 foreach (ListItem list in CheckBoxList1.Items)
        {
            if (list.Selected == true)
            { 

//your Insert Query
            
            }
        }


这篇关于如何在使用Loop时将所有选中的复选框列表值插入数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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