I'm just trying to do a quick proof of concept - want to bind a webgrid to an XmlDataSource with an XPath filter, or to a simple list of objects, then modify data in some of the rows as each row is data bound. Instead of the .NET event OnItemDataBound, I see the event InitializeRow, but I can't seem to get it to fire. Does anyone know of a sample that goes over this (easy) scenario? I've used the .NET GridView control in the past, but this is my first experiment with the UltraWebGrid control, and I can't seem to find samples to handle some of these types of scenarios.
Thanks,
Bryan
Bryan:
This should be pretty easy to do as you state. I created a couple of samples (attached) using the 2007 Volume 3 WebGrid that demonstrate the use of the event both binding to a SqlDataSource and also an XmlDataSource. Note to try the SQL sample you will have to update the connection string in the web.config. Its currently pointing to a Northwind database.
There should not be any magic, just connect the data source control and wire the InitializeRow event. If you create it via the property grid, you should see something like this get added to the WebGrid markup:
OnInitializeRow="UltraWebGrid1_InitializeRow"
You can of course add that manually yourself or even wire the event up in code:
this.UltraWebGrid1.InitializeRow+=new Infragistics.WebUI.UltraWebGrid.InitializeRowEventHandler(UltraWebGrid1_InitializeRow);
Hope that helps.
Devin
Devin:
I should have been more clear - I can get this to bind correctly if I specify the DataFile of the XmlDataSource; however, if I try to set the Data and Xpath properties of the XmlDataSource in the code behind (during Page_Load) using an XmlDocument's OuterXml object and my desired xPath, none of the data shows up in the grid. I have attached a web project illustrating the issue - check out page BindToXmlDoc.aspx. Wondering if I'm just missing some event - trying just DataBind() on the grid object to bind the data...