本文介绍了复选框列表中的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个下拉框,1个文本框和一个包含4个清单项目的清单列表.我已将清单列表数据类型作为sql中的位.如果DB中存在任何数据,则所有详细信息都将显示在页面上还有一个链接按钮,用户可以从中将数据添加到DB中.现在,当用户输入值并选择网页上的1个或多个复选框时,所有选择的详细信息都必须存储在数据库中. .pls help
I have 2 dropdown boxes,1 textbox and a checkbox list with 4 checklist items on my page.I have taken the checkbox list datatype as bit in sql.If there exists any data in DB,all the details would be displayed on the page.There is also a link button from where user can add the data into DB.Now when user enters the values and selects 1 or more check boxes on the webpage, all the selected details have to be stored in database.Im using MVC .pls help
推荐答案
dtbl = SPEmployee.Details(DateTime.Today);
for (int i = 0; i < cbxEmployeeAll.Items.Count; i++)
{
if (cbxEmployeeAll.Items[i].Selected == true)
{
infoPerformanceJudge.JudgeId = SPPerformanceJudge.PerformanceJudgeGetMax();
infoPerformanceJudge.Empcode = cbxEmployeeAll.Items[i].Value;
infoPerformanceJudge.Description = "";
infoPerformanceJudge.Status = true;
infoPerformanceJudge.Extra2 = "";
SPPerformanceJudge.PerformanceJudgeAdd(infoPerformanceJudge);
lblMessage.Visible = true;
lblMessage.ForeColor = Color.Green;
lblMessage.Text = "Saved successfully";
}
}
有关查看详细信息,
For View details,
foreach (DataRow drow in dtbl.Rows)
{
foreach (ListItem lstitem in cbxEmployeeAll.Items)
{
if (lstitem.Value == drow.ItemArray[1].ToString())
{
lstitem.Selected = true;
}
}
}
这篇关于复选框列表中的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!