单击链接按钮后,数据列表中的单选按钮会丢失选择 [英] Radio button in Data list loses selection after link button click
本文介绍了单击链接按钮后,数据列表中的单选按钮会丢失选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在数据列表中有一个单选按钮.我在该页面本身的数据列表外放置了一个链接按钮.但是在做出选择并单击链接按钮后,所选内容失去了单选按钮. h2_lin>解决方案
我不确定您如何处理后面代码中的单选按钮.我已经尝试过以下示例,并且工作完美.
foreach (DataListItem item in dlItem.Items) { RadioButton rbt = (RadioButton)item.FindControl("rbtClick"); if (rbt.Checked) { Response.Write("Checked"); } else { Response.Write("Un-Checked"); } }
请确保未单击链接按钮来调用数据列表绑定.由于它可能会重新绑定数据列表并丢失先前的选择.
Hi,
I have a radio button in data list.I placed a link button outside the data list in that page itself.But after making selection and clicking the link button the selection loses of radio button.How can i preserve this?
解决方案
I am not sure how you are dealing with the radio button in code behind. I have tried below example and working perfect.
foreach (DataListItem item in dlItem.Items) { RadioButton rbt = (RadioButton)item.FindControl("rbtClick"); if (rbt.Checked) { Response.Write("Checked"); } else { Response.Write("Un-Checked"); } }
Please make sure that datalist binding is not calling on link button click. As it may re-bind the datalist and lost the previous selection.
这篇关于单击链接按钮后,数据列表中的单选按钮会丢失选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文