![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have a DataGrid from which the datasource is a SqlDataReader based on a SQL Server Stored Procedure. This SP returns columns will NULL values. When I DataBind() to the DataGrid, all is well. It's when I want to detect these null values in the ItemDataBound event that...well...I can't detect them. I've tried everything I can think of. Why does'nt (e.Items.Cells[1].Text == null) work? tia, j |
#3
| |||
| |||
|
|
J, You should only use datareader if you want to iterate and process the data being returned. for assigning datasource consider using dataset DataReader keep the connection open till you explicitly close them or if you command open specifies it. As for your query.. i would suggest you you use Returns the first nonnull expression among its arguments. Syntax COALESCE ( expression [ ,...n ] ) ie you specify say coalesce(columnname, '') if the value in column is null it will return '' which is empty string -- Regards, Hermit Dave (http://hdave.blogspot.com) "Jordan" <jfritts (AT) learn (DOT) colostate.edu> wrote in message news:O8wYJfdmEHA.1656 (AT) TK2MSFTNGP09 (DOT) phx.gbl... I have a DataGrid from which the datasource is a SqlDataReader based on a SQL Server Stored Procedure. This SP returns columns will NULL values. When I DataBind() to the DataGrid, all is well. It's when I want to detect these null values in the ItemDataBound event that...well...I can't detect them. I've tried everything I can think of. Why does'nt (e.Items.Cells[1].Text == null) work? tia, j |
#4
| |||
| |||
|
|
I have a DataGrid from which the datasource is a SqlDataReader based on a SQL Server Stored Procedure. This SP returns columns will NULL values. When I DataBind() to the DataGrid, all is well. It's when I want to detect these null values in the ItemDataBound event that...well...I can't detect them. I've tried everything I can think of. |
#5
| |||
| |||
|
|
Thanks Dave. Unfortunately, I'm using a GROUPING ROLLUP query so I can't detect the null values using the COALESCE statement for the field I'd like to. I ended up making this query a subquery as it does seem easier to detect any string in .NET than a null value. I do use SqlDataReader = Cmd.ExecuteReader(CommandBehavior.CloseConnection) . Is this any different than a DataSet - probably more is passed back to the client in the datareader instance if anything I'm guessing. It's truly sad that functionaliy seems to have been removed from .NET. Detecting nulls with a simple comparision is truly an *everyday* need. j "Hermit Dave" <hermitd.REMOVE (AT) CAPS (DOT) AND.DOTS.hotmail.com> wrote in message news:OHUjLqdmEHA.3172 (AT) TK2MSFTNGP10 (DOT) phx.gbl... J, You should only use datareader if you want to iterate and process the data being returned. for assigning datasource consider using dataset DataReader keep the connection open till you explicitly close them or if you command open specifies it. As for your query.. i would suggest you you use Returns the first nonnull expression among its arguments. Syntax COALESCE ( expression [ ,...n ] ) ie you specify say coalesce(columnname, '') if the value in column is null it will return '' which is empty string -- Regards, Hermit Dave (http://hdave.blogspot.com) "Jordan" <jfritts (AT) learn (DOT) colostate.edu> wrote in message news:O8wYJfdmEHA.1656 (AT) TK2MSFTNGP09 (DOT) phx.gbl... I have a DataGrid from which the datasource is a SqlDataReader based on a SQL Server Stored Procedure. This SP returns columns will NULL values. When I DataBind() to the DataGrid, all is well. It's when I want to detect these null values in the ItemDataBound event that...well...I can't detect them. I've tried everything I can think of. Why does'nt (e.Items.Cells[1].Text == null) work? tia, j |
#6
| |||
| |||
|
|
DataRowView drv = ((DataRowView) e.Item.DataItem); if (drv.Row.IsNull("myNullableColumn")) { // Column is NULL in this row } |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |