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
I'm assuming that your "ExemptSupervisor" column becomes a Boolean value in your data source, which is likely why it's appearing as a checkbox. Assuming that this is the case, then you simply need to cast the value of your cell from an Object to a Boolean:
If CType(e.Row.Cells.FromKey("ExemptSupervisor").Value, Boolean) = False Then '<= Level of error
By the way, if you need your column to be stored in ViewState, I also suggest you add it to your grid in a different manner, as illustrated here:
' ExemptSupervior 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
"ExemptSupervisor" is a boolean value in the database but nothing is appearing on the web grid, not a checkbox, simply an empty space. I did make the changes you suggested and again, no value is being written to the grid.
Using: If CType(e.Row.Cells.FromKey("ExemptSupervisor").Value, Boolean) = False Then I get the following error message: Object reference not set to an instance of an object
1> How do I write the Boolean value to the grid?2> How do I then capture the value to use it the the "If/Else/End" statement?
Thank you.
I think we need to cross the bridge of "what .NET data type do you have?" first. A value of -1 is clearly not a boolean value, so I don't know what behavior to expect.
I double-checked the data type is "bit".
What is the underlying database? Is it SQL Server 2005, SQL Server 2008, or something else?
Good Morning,
The underlying data base is SQL Server 2005. Notably, there is no option to select Boolean hence I have been using "bit" when I needed a "True" "False" data option. Which was not an issue within Visual Studio, but the same value does not write to the UltraWebGrid.
The "bit" datatype in SQL Server 2005 is the right value to use as a boolean value. What I don't understand at this stage is why it's being pulled into your .NET data source as a number value, since I'd expect it to be pulled in as an actual boolean value (as in the System.Boolean data type).
What kind of object are you using to pull the data into .NET? Can you confirm what data type is being used in that object for this field?
At this point, I'm passing this thread over to Developer Support to provide you with further aid. Everything that's been described so far should likely have worked, to the best of my knowledge, and it will take further research to determine why things aren't working. Developer Support will create a support case for you and contact you through that case.
Nothing works.
Good News! (sort-of)
Using Microsoft's AdventureWorks database, the replacement for Northwind, using a table which has Boolean values resulted in the UltraWebGrid dataobject writing "True' and "False".
The downside is the datatype used within AdventureWorks is not an option within SQL Server 2005, which is "UnknownType".
Hmm, the actual values within the column is True and False, not "0" or "1", which I currently have. I will change the "0" and "1" to "True" and "False" to View the output.
TY
WebGrid should already be doing this. It implicitly provides checkboxes for colums that use the System.Boolean data type, without needing any specific code to do so. I'm suspecting that there's something about the data structure itself that is keeping the grid from identifying your column as a boolean.
Can you reproduce this behavior in a sample that we can run and debug? I suggest using the Products table using the Northwind sample database, since it has a Discontinued column which is a "bit" datatype in SQL Server.
Happy Easter!
I am looked at this problem and found out the following: when I used the GridView object the Boolean value appeared as a checkbox so that I can grab that value to use in a conditional statement. However with the UltraWebGrid no value is reflected; the column is blank.
Only from within Sql Server Query Analyzer, the "-1" value appears.
So, I am thinking that there is a major difference between how Visual Studio's GridView object and infragistics UltraWebGrid object interprets Boolean values. The goal is to have the UltraWebGrid recognize Boolean values.