关于动态复选框 [英] About Dynamic Checkboxes
问题描述
朋友们,
我通过在页面加载中从XML文档中读取值来动态创建了复选框.
现在的问题是,我必须检查CB(复选框)并单击提交"按钮,将其提交到数据库中.
因此,如何在提交单击事件时将复选框值插入数据库.
所以如果有人有解决方案,请帮帮我..
Hi friends,
I have Created Check Boxes dynamically by reading values from XML document in page load.
Now problem is that i have to check CB(Check Boxes) and on submit button click it get submitted into database.
So how can I insert check box values into database on submit click event.
so if any one has solution please help me out..
推荐答案
通过在页面加载中从XML文档中读取值来动态创建复选框
I have Created Check Boxes dynamically by reading values from XML document in page load
不要在页面加载中创建复选框,请尝试在Page_Init
事件中创建它.这样可以防止控件丢失其视图状态.它将自动恢复视图状态.
您需要使用:
Don''t create your checkboxes in page load, try creating it in Page_Init
event. This will prevent the controls to losing it''s viewstate. it will restore the viewstate automatically.
You need to use:
CheckBox chk = (CheckBox)Page.FindControl("Chk1");
查找复选框.
--Amit
To find the checkboxes.
--Amit
对此有很多解决方案,但是当您单击复选框时,请尝试此方法,以调用Java脚本函数并将值添加到具有逗号分隔值的隐藏字段中.
现在,当您单击按钮时,将获取隐藏字段值并插入数据库中.
有点棘手.
There is many solution for this but try this one when you click on the checkbox call the java script function and add values into hidden field with comma separated values
Now when you click on the button get hidden field value and insert in the database.
Its little tricky.
这篇关于关于动态复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!