conditional data/table display

  • Thread starter Thread starter Steve Bywaters
  • Start date Start date
S

Steve Bywaters

In conventional ASP, I would often conditionally display some rows of a
(data-loaded) table - for example, group headers/footers.
Simple to do...

In ASP.NET, with the use of DataGrid (etc), this would not seem to be
possible (?)
But if I continue to use my 'traditional' approach (ie conditional table-row
display), perhaps I'm not making the best of the new technology....?
But if I can't get the *result* I want with the new tech, then....
(etc, etc)

Any views on this balance of tech vs. funtion?

Steve
 
U can do this trapping the event of Datagrid
ItemDataBound

The code will look some thing below in C#


/* Sample Code begins here*/
private void UrDatagrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.DataItem !=null)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
DataRow dr =
((System.Data.DataRowView)e.Item.DataItem).Row;
//U can apply style any thing the
DataTime(e.Item.DataItem)
if (UrCondition)
{
e.Item.Visible=false;
}
else
{
e.Item.Visible=false;
}
}
}
}
/* Sample Code Ends here*/

HTH

Thanks,

sswalia
MCSD, MCAD, OCA
 
Back
Top