I have a grid using GridBoundColumns. The first column is a GridButtonColumn whose Text property is blank. When the user clicks the button, the user's login Id is stored in a database table and the button's text is set to the user's login Id. This all happens in the grid's ItemCommand event. The code is:
That code works great and the button's text is updated as desired. The problem is when the user goes to the next page in the grid and the returns to the previous page, the text is gone. How can I keep the text from disappearing?
Thanks,
James
If e.CommandName = "Assign" Then Dim item As GridDataItem = CType(e.Item, GridDataItem) Dim strJobNumber As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("Job_Number") Dim strButtonText As String = CType(item("button").Controls(0), Button).Text Dim NTLoginID As String = GetCurrentUser() If String.IsNullOrEmpty(strButtonText) Then Dim _db As New MyAssembly.DataContext(ConfigurationManager.ConnectionStrings("MyCNString").ConnectionString) Dim rslt = _db.TMSearchAssignments.Where(Function(x) x.JobNumber.Equals(strJobNumber)).FirstOrDefault If Not rslt Is Nothing Then CType(item("button").Controls(0), Button).Text = rslt.NTLoginID Exit Sub Else db.StoredProcedureRepo.sp_Insert_TMSearchAssignment(strJobNumber, NTLoginID, False) CType(item("button").Controls(0), Button).Text = NTLoginID End If End If End IfThat code works great and the button's text is updated as desired. The problem is when the user goes to the next page in the grid and the returns to the previous page, the text is gone. How can I keep the text from disappearing?
Thanks,
James