<asp:DataGrid id='DataGrid1' OnItemDataBound=ItemDB runat='server'></asp:DataGrid>
VB.NET
Private Sub Page_Load(sender As Object, e As System.EventArgs)
’ Put user code to initialize the page here
If Not Page.IsPostBack Then
’Populate the DataGrid
End If
End Sub ’Page_Load
Protected Sub ItemDB(ByVal s As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
If e.Item.Cells(1).Text = ' ' Then
e.Item.Cells(1).Text = 'No data'
End If
End If
End Sub ’ItemDB
C#
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!Page.IsPostBack )
{
//Populate the DataGrid
}
}
protected void ItemDB (Object s , System.Web.UI.WebControls.DataGridItemEventArgs e )
{
if ((e.Item.ItemType ==ListItemType.Item) ||(e.Item.ItemType ==ListItemType.AlternatingItem))
{
if( e.Item.Cells[1].Text == ' ')
{
e.Item.Cells[1].Text = 'No data';
}
}
}
In Cells[x]/Cells(x) x=> index number
Share with