samedi 25 avril 2015

Need to Get data value prior to binding to row in listview


I have a ListView object in asp.net (C#) where I also have a ListView_ItemDataBound() method that is populated using a sqlDataSource.

In some cases, I would like to be able to insert a row in the ListView prior to the current record being bound. I.e., as the rows are being populated, I need to be able to read the value that is about to be bound and then insert a "header" row mid stream before the current row of data is added to the ListView. In the case of the ItemDataBound event, the data seems to be already bound to the control so the rows being added are actually one ListView row too late for me to do anything.

ListView_ItemDataBound()
{
    System.Data.DataRowView rowView = e.Item.DataItem as System.Data.DataRowView;


 //Psuedo code of what I'd like
 //if rowView["some_field"]==123 then insert row prior to this row being bound
    }

I'm relatively new to asp.net and come from a classic asp background so maybe I'm thinking and going about this all wrong. Any suggestions would be appreciated.


Aucun commentaire:

Enregistrer un commentaire