I need to execute a sql statement based on the boolean value in the column, ExemptSuperviors, however the value is not being written to the grid. Hence, I am not getting the value for the sql statement. How can I resolve this issue, please.
Even the boolean value cannot be displayed, I do need it for the sql statement.
I have:
' ExemptSupervior
.Columns.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridColumn)
With .Columns(.Columns.Count - 1).Hidden = False.Header.Caption = "ExemptSupervior".Width = 25.IsBound = True.BaseColumnName = "ExemptSupervior".Key = "ExemptSupervior"End With
Along with:If e.Row.Cells(e.Row.Cells.IndexOf("ExemptSupervisor")).Value = "-1" Then <= Level of error
If (e.Row.Cells(e.Row.Cells.IndexOf("LunchTime")).Value = "3") Then do some stuff Else If (e.Row.Cells(e.Row.Cells.IndexOf("LunchTime")).Value = "6") Then do some other stuff End
The checkbox is showing as unchecked for value that is True, which ought to be checked.
And if the checkbox is checked for True values, then how would I capture the True value to use in the If/Else/End If statement. Or, would the custome option yield "True" or "False".
That's why the value isn't showing as a checkbox, then. What's the .NET data type of this value?
You might be able to get this data to display as a checkbox by setting the column's Type property to Infragistics.WebUI.UltraWebGrid.ColumnType.Checkbox. If I recall correctly, any nonzero, non-empty, not-null value should will be treated as "checked," while a zero, null, or empty value will be treated as "not checked." I don't know what the grid will use when updating the value of cells in this column, however.
Depending on the data type you're getting from your database, you may need to either update your stored procedure to return a boolean value, or possibly use an unbound boolean column in your grid to handle the actual display of your checkboxes.
When I run the stored procedure within VS 2005, result for ExemptSupervisor is "-1" for a True value.
I am using a stored procedure: Protected Sub BindugGridExceptions()
Dim SQLConnection As New SqlClient.SqlConnection Dim SQLGridCommand As New SqlClient.SqlCommand Dim SQLGridParam As SqlClient.SqlParameter
SQLConnection.ConnectionString = ConfigurationManager.ConnectionStrings("ACS").ConnectionString
SQLConnection.Open() SqlClient.SqlConnection.ClearPool(SQLConnection)
SQLGridCommand.Connection = SQLConnection SQLGridCommand.CommandType = CommandType.StoredProcedure SQLGridCommand.CommandText = "usp_ExcelReports"
With Me SQLGridParam = New SqlClient.SqlParameter SQLGridParam.ParameterName = "@LocationCode" 'DropDownList SQLGridParam.Value = .ddlLocation.SelectedValue SQLGridCommand.Parameters.Add(SQLGridParam)
SQLGridParam = New SqlClient.SqlParameter SQLGridParam.ParameterName = "@BeginDate" 'Calendar Object SQLGridParam.Value = .lblBeginDate.Text SQLGridCommand.Parameters.Add(SQLGridParam)
SQLGridParam = New SqlClient.SqlParameter SQLGridParam.ParameterName = "@EndDate" 'Calendar Object SQLGridParam.Value = .lblEndDate.Text SQLGridCommand.Parameters.Add(SQLGridParam)
Dim GridReader As System.Data.SqlClient.SqlDataReader GridReader = SQLGridCommand.ExecuteReader(CommandBehavior.CloseConnection)
If GridReader.HasRows Then
Do While (GridReader.Read()) Dim drRow As DataRow = .dsAttendance.Tables("usp_ExcelReports").NewRow For i As Int32 = 0 To .dsAttendance.Tables("usp_ExcelReports").Columns.Count - 1 drRow.Item(.dsAttendance.Tables("usp_ExcelReports").Columns(i).ColumnName) = GridReader(.dsAttendance.Tables("usp_ExcelReports").Columns(i).ColumnName) Next .dsAttendance.Tables("usp_ExcelReports").Rows.Add(drRow) Loop
.dsAttendance.Tables("usp_ExcelReports").AcceptChanges()
End If
.ugGridExceptions.DataSource = Me.dsAttendance.Tables("usp_ExcelReports").DefaultView .ugGridExceptions.DataBind()
SQLGridCommand.Dispose() SQLGridCommand = Nothing
SQLConnection.Close()
End With
End Sub
***
The database column ExemptSupervisors does not accept NULL values.
*****Protected Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles ugGridExceptions.InitializeLayout
With Me.ugGridExceptionsMe.ugGridExceptions.DisplayLayout.Pager.AllowPaging = TrueMe.ugGridExceptions.DisplayLayout.NoDataMessage = "No employee records match your search criteria" 'message no showing up in the grid
Me.ugGridExceptions.DisplayLayout.Pager.PageSize = RecordsPerPage
.Columns.Clear() 'without columns.clear the first column is column 0 in the grid.
' UserID
.Columns.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridColumn)With .Columns(.Columns.Count - 1).Width = 45.Hidden = False.Header.Caption = "User ID".IsBound = True.BaseColumnName = "UserID".Key = "UserID".AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.RowTemplateOnlyEnd With
' Employee
.Columns.Add(New Infragistics.WebUI.UltraWebGrid.UltraGridColumn)With .Columns(.Columns.Count - 1).Width = 150.Hidden = False.Header.Caption = "Employee".IsBound = True.BaseColumnName = "Employee".Key = "Employee".AllowGroupBy = Infragistics.WebUI.UltraWebGrid.AllowGroupBy.Yes.AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.RowTemplateOnlyEnd With
Dim colExempt As New Infragistics.WebUI.UltraWebGrid.UltraGridColumn(True).Columns.Add(colExempt)With colExempt.Hidden = False.Header.Caption = "ExemptSupervior".Width = 25.IsBound = True.BaseColumnName = "ExemptSupervior".Key = "ExemptSupervior"End With
'more columns
How are you pulling the data into .NET? What kind of data object are you using? Is the value coming into .NET as an actual boolean value? Does the database field accept null values?
If the value isn't being shown as a checkbox in the first place, then I'm suspecting that it's not coming into .NET as a boolean value either. That's the first thing we'll want to figure out.