要实现的要求如下:
有一个DropDownList框,通过下拉框中选择值来改变CheckBoxList绑定的项。选择CheckBoxList里的值后,保存选中的值在A变量,取消了选中的值,移出A变量里对应的值,当用户重新选择DropDownList框值,A变量的值不能清空,继续追加用户选择的值。直到用户点击确定按钮,才把A变量的值保存到数据库。应该怎么实现?
有一个DropDownList框,通过下拉框中选择值来改变CheckBoxList绑定的项。选择CheckBoxList里的值后,保存选中的值在A变量,取消了选中的值,移出A变量里对应的值,当用户重新选择DropDownList框值,A变量的值不能清空,继续追加用户选择的值。直到用户点击确定按钮,才把A变量的值保存到数据库。应该怎么实现?
解决方案 »
- 请教将gridview中文本换行的方法
- web.config 下面 pages tag无效
- 请问怎样对GridView模板列EditItem中的DropDownList进行数据绑定
- 如何获取查询结果的数量并打印
- [恳请大家帮忙]Ajax的问题我已经弄很长时间
- DataBinder.Eval:“System.Data.DataRowView”不包含名称为 qiche_name 的属性。 请问这是哪错了?谢谢了
- 请教高手。。。。。。。。。。。
- 如何操IFRAME里面的控件
- WebService用一维字符串数组做参数,java如何调用?
- 如何在页面加载的时候给TEXTBOX设置焦点?
- |zyciis| 老问题,如何重启网站,开始的修改WebConfig的办法不行,在服务器提示访问web.config被拒绝,第二贴 说明我的问题
- 登陆后,页面提示说,保留用户信息(就是我下次登陆的时候,不用再输入用户名和密码),这样的功能代码你有吗?
ViewState["selstr"]=Request["input的id"];
else
ViewState["selstr"]=ViewState["selstr"].ToString()+","+Request["input的id"];
按钮的事件
string aa ="";
if(ViewState["selstr"]==null)
aa=Request["input的id"];
else
aa=ViewState["selstr"].ToString()+","+Request["input的id"];
<td>
<input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" /><label for="CheckBoxList1_0">信息技术经理·信息技术主管</label></td>
<td>
<input id="CheckBoxList1_1" type="checkbox" name="CheckBoxList1$1" /><label for="CheckBoxList1_1">信息技术专员</label></td>
<td>
<input id="CheckBoxList1_2" type="checkbox" name="CheckBoxList1$2" /><label for="CheckBoxList1_2">产品经理·品牌经理</label></td>
</tr>
<tr>
<td>
<input id="CheckBoxList1_3" type="checkbox" name="CheckBoxList1$3" /><label for="CheckBoxList1_3">项目经理·项目主管</label></td>
<td>
<input id="CheckBoxList1_4" type="checkbox" name="CheckBoxList1$4" /><label for="CheckBoxList1_4">项目执行·协调人员</label></td>
<td>
<input id="CheckBoxList1_5" type="checkbox" name="CheckBoxList1$5" /><label for="CheckBoxList1_5">架构师</label></td>
</tr>
怎么用JS控制 把所有选择的值用","连接啊,能不能给点代码,分不够可以加的...
function selectstr(){
var tmpstr;
for(int i=0;i<document.Form1.CheckBoxList1.length;i++)
{
if(!document.Form1.CheckBoxList1.options[i].selected){
if(tmpstr.indexOf(document.Form1.CheckBoxList1.options[i].text)>0)
{
tmpstr.replace(","+document.Form1.CheckBoxList1.options[i].text,"");
}
}
else
{
if(tmpstr.indexOf(document.Form1.CheckBoxList1.options[i].text)<0)
{
tmpstr +=","+document.Form1.CheckBoxList1.options[i].text;
}
}
} document.Form1.selectinput.value =tmpstr;
}//PageLoad中
CheckBoxList1.Attributes.Add("onclick","selectstr()");
以上代码未经测试其实还有更取巧的办法...
你可以按照DropDownList的item数事先将 item.Count 个CheckBoxList绑定在页面中
用js控制,选择哪项就显示哪个CheckBoxList提交的时候,循环所有的CheckBoxList的选中就可以了。
aspx页面将id绑定到CheckBox 的CssClass
上面写了很js方法
foreach (DataListItem dlia in DataList1.Items)
{
CheckBox cha = (CheckBox)(dlia.FindControl("CheckBox1"));
if(cha.Checked)
{
id= cha.CssClass
}
}