Click here to Skip to main content
15,438,202 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.


VB
<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.
Posted
Updated 17-May-17 21:35pm
v2
Comments
F-ES Sitecore 18-May-17 4:16am     CRLF
The fact that your checkboxes are dynamically created is a very important piece of information that you are not telling people. I told you in your other thread what the problem was and what you need to do to fix it. It doesn't matter how many times you ask the same question the answer is not going to change. Any dynaimcally created items needs to be created on each postback and you are not doing that. https://forums.asp.net/t/1965764.aspx?Dynamically+creating+controls

1 solution

 
Share this answer
 
Comments
VinKot 18-May-17 3:51am    
In my case, i can't make any changes in client side as the template controls and gridView are creating dynamically in runtime [in LoadGridViewSignatoryGroup()]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900