I need a sample code that will disable a selected cell in a DataGridView using VB.net code.
in my cell(10) there were two controls as TextBox. Only txtEntryDateTo_Store should be disabled.
Below is my sample code, kindly insert your code in between my script..
Dim todaydate As DateTime = DateTime.Now
Dim gridViewRow As GridViewRow
Dim intApprCount As Integer = 0
If grdTransaction_Store.Rows.Count > 0 Then
For Each gridViewRow In grdTransaction_Store.Rows
Dim lblEntryDateFrom_Store As Label = CType(gridViewRow.Cells(9).FindControl("lblEntryDateFrom_Store"), Label)
Dim lblExitDateFrom_Store As Label = CType(gridViewRow.Cells(9).FindControl("lblExitDateFrom_Store"), Label)
Dim txtEntryDateTo_Store As TextBox = CType(gridViewRow.Cells(10).FindControl("lblEntryDateTo_Store"), TextBox)
Dim txtExitDateTo_Store As TextBox = CType(gridViewRow.Cells(10).FindControl("lblExitDateTo_Store"), TextBox)
Dim ContractEntryDate As DateTime = Convert.ToDateTime(lblEntryDateFrom_Store.Text)
If ContractEntryDate.Month < todaydate.Month Then
'
' Place your sample code that will disable this current cell..
' gridViewRow.Cells(10).FindControl("lblEntryDateTo_Store")
'
'
End If
Next
End If
in my cell(10) there were two controls as TextBox. Only txtEntryDateTo_Store should be disabled.
Below is my sample code, kindly insert your code in between my script..
Dim todaydate As DateTime = DateTime.Now
Dim gridViewRow As GridViewRow
Dim intApprCount As Integer = 0
If grdTransaction_Store.Rows.Count > 0 Then
For Each gridViewRow In grdTransaction_Store.Rows
Dim lblEntryDateFrom_Store As Label = CType(gridViewRow.Cells(9).FindControl("lblEntryDateFrom_Store"), Label)
Dim lblExitDateFrom_Store As Label = CType(gridViewRow.Cells(9).FindControl("lblExitDateFrom_Store"), Label)
Dim txtEntryDateTo_Store As TextBox = CType(gridViewRow.Cells(10).FindControl("lblEntryDateTo_Store"), TextBox)
Dim txtExitDateTo_Store As TextBox = CType(gridViewRow.Cells(10).FindControl("lblExitDateTo_Store"), TextBox)
Dim ContractEntryDate As DateTime = Convert.ToDateTime(lblEntryDateFrom_Store.Text)
If ContractEntryDate.Month < todaydate.Month Then
'
' Place your sample code that will disable this current cell..
' gridViewRow.Cells(10).FindControl("lblEntryDateTo_Store")
'
'
End If
Next
End If