This may be an alternate way not sure if it works with e arguments or not, but I assume it will
If IsDbNULL(e.Item.Cells(0).T
e.Item.Cells(0).Text = "Not defined"
End If
Main Topics
Browse All TopicsHi, I have datagrid that is bound to a SQL datasource. The query retuns <NULL> values. I would like to repace all <NULL> value in my datagrid with
some other text.
How would I do it via the ItemDataBound event..
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The way I've to do sometimes is with checking out for "" (empty string) and (space)...
Following is the code for that..
--------------------------
private void DataGrid1_ItemDataBound(ob
{
switch( e.Item.ItemType )
{
case ListItemType.Item:
case ListItemType.AlternatingIt
if( e.Item.Cells[0].Text == "" || e.Item.Cells[0].Text == " " )
{
e.Item.Cells[0].Text = "0";
}
break;
}
}
--------------------------
-tushar
Thanks, do you know what the C# code would be like
If have tried
if (e.items.cells[0].text == DbNull) >>> error that DbNull is an class also tried DbNull.value ..cannot compare string to bool
also tried
if (e.items.cells[0].text == null) >> nothing so to if i replace null with ""..
When i do a len on the text it is = 6 , this point to the fact that that the system does get "<NULL>" from database
Business Accounts
Answer for Membership
by: nauman_ahmedPosted on 2004-10-29 at 02:57:10ID: 12442652
Something like the following should work:
Val sender As Object, ByVal e As System.Web.UI.WebControls. DataGridIt emEventArg s) Handles DataGrid1.ItemDataBound
Private Sub DataGrid1_ItemDataBound(By
If e.Item.Cells(0).Text Is Nothing Then
e.Item.Cells(0).Text = "Not defined"
End If
End Sub
Best, Nauman.