I know this should be simple and I have done it before, but for some reason I can't see why this isn't working. I have a very small grid with 3 columns and all I want to do is place one of two columns into edit mode in the PreRender method. If a hidden column in the row is a certain value, I want to place it's corresponding visible column into edit mode and color the first column red. In debug the values are being compared properly and it does hit the line of code that sets the column into edit mode, however it sets both columns into edit mode for every row instead of the just the column that I want it to (even though it doesn't hit the code to set the other column into edit mode it still somehow is set to edit). If both hidden columns are invalid I want to set both visible columns into edit mode. As for coloring the text of the first column red it simply has no effect even thoguh the code is hit.
Can somebody please help me with this it seems like it should be very simple. Thanks!
Can somebody please help me with this it seems like it should be very simple. Thanks!
Private Sub rgC_PreRender(sender As Object, e As System.EventArgs) Handles rgC.PreRender If Not IsPostBack Then For Each item As GridItem In rgC.MasterTableView.Items If (TypeOf item Is GridDataItem) Then Dim lblEmpId As Label = CType(item.FindControl("lblEmpId"), Label) Dim lblEmpNo As Label = CType(item.FindControl("lblEmpNo"), Label) 'Contains the null value if invalid Dim lblJobCode As Label = CType(item.FindControl("lblJobCode"), Label) Dim lblJobNum As Label = CType(item.FindControl("lblJobNum"), Label) 'Contains the null value if invalid Dim lblCardId As Label = CType(item.FindControl("lblCardId"), Label) If (lblEmpNo.Text = "") Then lblCardId.ForeColor = Drawing.Color.Red item.Edit = True End If If (lblJobCode.Text = "") Then lblCardId.ForeColor = Drawing.Color.Red item.Edit = True End If End If Next rgC.Rebind() End If End Sub