conditional data/table display

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
 
S

SSW

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top