动态复选框在ASP.Net中的页面回发后失去选择 - C# [英] Dynamic checkboxes losing selection after page postback in ASP.Net - C#

查看:55
本文介绍了动态复选框在ASP.Net中的页面回发后失去选择 - C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 

我有一个asp.net页面,我们根据记录的数量生成动态复选框(页面上的所有控件都是动态添加的)数据库表,我们在这些复选框上触发了事件。

I have an asp.net page, where we are generating dynamic checkboxes (all controls on the page are dynamically added) based on the number of records in the database table and we have event firing on these checkboxes.

我每次选中复选框时都试图将数据插入数据库(每一行)。对于这些复选框,我们将viewstate的启用和自动回发设置为true。

I am trying to insert data into database(every row) eachtime the checkbox is checked. We have viewstate enabled and auto postback set to true for these checkboxes.

在页面回发后,我丢失了之前检查过的复选框状态。任何人都可以建议我这样做吗?

I am losing the previously checked checkbox state after the page postback. Can anyone please suggest me a way to do this?

谢谢

推荐答案

在页面回发后我丢失了之前检查过的复选框状态。任何人都可以建议我这样做吗?

您可以使用会话对象来保留回发时复选框的状态。高性能ASP.NET解决方案不使用viewstate,因为在客户端和服务器端之间拖动视图状态数据会降低解决方案的速度。您还可以在窗体的隐藏字段中保存
复选框的状态。

You can use a session object to hold the state of the checkbox on postback. High performance ASP.NET solutions do not use viewstate, because viewstate data is dragged around between client and server sides slowing the solution down. You can also hold the state of the checkbox in a hidden field on the form.

无论如何,无论如何,你必须在往返时重建控件,或者你使用JavaScript和JQuery在客户端完成整个操作。

Either way, you have to rebuild the control each time on the roundtrip anyway, or you do the whole thing on the client-side using JavaScript and JQuery.

可以在ASP.NET论坛中讨论ASP.NET。

ASP.NET can be discussed at the ASP.NET forums.

http:// forums .asp.net /


这篇关于动态复选框在ASP.Net中的页面回发后失去选择 - C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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