Gridview数据在回发时被清除 [英] Gridview data getting cleared on postback
问题描述
我正在加载.aspx中的用户控件以显示gridView并在代码后面的列中动态创建CheckBox模板字段。无论何时我选中或取消选中,都会触发自动回复。
由于我在page_load中绑定()网格,它在回发后跳过重新绑定gridView(如果添加了Not IsPostback()条件)
如何在PostBack之后使用Checkbox更改保留GridView中的数据?用户控件与其他标签和文本框控件一起放在aspx中。
请建议我如何在回发后从代码中重新获取GridView数据。
< pre> 私有 Sub Page_Load( ByVal sender 作为 对象, ByVal e As System.EventArgs)句柄 我 .Load
Dim 值( 5 ) As 字符串
Dim totalCount 作为 整数
Dim dtcustAcctSignRelation = 新 DataTable ()
Dim lstCustInfo As ArrayList = TryCast 跨度>(会话( CustInfo),ArrayList)
Dim i 作为 整数 = 0
如果 不 Page.IsPostBack 然后
对于 每个值作为 字符串 在 lstCustInfo
值(i)=值
i = i + 1
下一步
Calendar1.Visible = False
lstRegInfo = CType (会话( secureURL),全局 .System.Collections.Generic.List( of String ))
HideLeftPanelFromMasterPage()
InitializeCustInfoPanel(Values)
dtcustAcctSignRelation = RetrieveBSUCustomer(Values , 1 ,totalCount,dtcustAcctSignRelation)' ***获取DataTable值
LoadGridViewSignatoryGroup(值( 0 )。ToString(),dtcustAcctSignRelation)' ***创建模板字段并将数据绑定到GridView
结束 如果
结束 Sub
我有什么三编辑:
尝试使用ViewState逻辑,不确定它是否会保留复选框更改。
看看这个:在回发后取消选中CheckBox
I am loading the user control in .aspx to display the gridView and dynamically creating the CheckBox template field in columns in code behind.Whenever i check or uncheck, autopostback is triggered.
Since i bind() the grid in page_load, it Skip the rebind the gridView after postback (if Not IsPostback() condition is added)
How to retain the data in the GridView with Checkbox changes was made after PostBack? User Control is placed on in aspx along with other labels and text box controls.
Please suggest me how to regain the GridView data from code behind after postback.
<pre> Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Values(5) As String
Dim totalCount As Integer
Dim dtcustAcctSignRelation = New DataTable()
Dim lstCustInfo As ArrayList = TryCast(Session("CustInfo"), ArrayList)
Dim i As Integer = 0
If Not Page.IsPostBack Then
For Each value As String In lstCustInfo
Values(i) = value
i = i + 1
Next
Calendar1.Visible = False
lstRegInfo = CType(Session("secureURL"), Global.System.Collections.Generic.List(Of String))
HideLeftPanelFromMasterPage()
InitializeCustInfoPanel(Values)
dtcustAcctSignRelation = RetrieveBSUCustomer(Values, 1, totalCount, dtcustAcctSignRelation) '*** Getting DataTable values
LoadGridViewSignatoryGroup(Values(0).ToString(), dtcustAcctSignRelation) '*** Creating Template Fields and binding data to GridView
End If
End Sub
What I have tried:
Tried to using ViewState logic, not sure it will retain the Checkbox changes made.
Check this out: CheckBox is unchecked after Postback
这篇关于Gridview数据在回发时被清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!